diff --git a/src/benchmark-config.json b/src/benchmark-config.json index 6a82e02..b6bec95 100644 --- a/src/benchmark-config.json +++ b/src/benchmark-config.json @@ -106,7 +106,8 @@ "openrouter": { "models": [ "horizon-alpha", - "horizon-beta" + "horizon-beta", + "sherlock-think-alpha" ] }, "alibaba": { diff --git a/src/benchmark/results.json b/src/benchmark/results.json index 7257d59..6bf7219 100644 --- a/src/benchmark/results.json +++ b/src/benchmark/results.json @@ -657442,5 +657442,5935 @@ "error": null } ] + }, + { + "sql": "\nSELECT count() FROM github_events WHERE event_type = 'WatchEvent' LIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "count()": 7305112 + } + ], + "meta": [ + { + "name": "count()", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.004084876, + "rows_read": 24577, + "bytes_read": 24592 + }, + "executionTime": 0.107, + "requestId": "01KA4B3PNYKCS98XRME7S9RZEB", + "length": 21 + }, + "name": "pipe_01.pipe", + "question": { + "name": "pipe_01.pipe", + "content": "DESCRIPTION >\n Count all stars\n\nNODE endpoint\nSQL >\n SELECT count() FROM github_events WHERE event_type = 'WatchEvent'\n\nTYPE endpoint", + "question": "Count all stars" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.782, + "totalDuration": 5.446, + "tokens": { + "promptTokens": 4576, + "completionTokens": 609, + "totalTokens": 5185 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT count() FROM github_events WHERE event_type = 'WatchEvent' LIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "count()": 7305112 + } + ], + "meta": [ + { + "name": "count()", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.004084876, + "rows_read": 24577, + "bytes_read": 24592 + }, + "executionTime": 0.107, + "requestId": "01KA4B3PNYKCS98XRME7S9RZEB", + "length": 21 + }, + "name": "pipe_01.pipe", + "question": { + "name": "pipe_01.pipe", + "content": "DESCRIPTION >\n Count all stars\n\nNODE endpoint\nSQL >\n SELECT count() FROM github_events WHERE event_type = 'WatchEvent'\n\nTYPE endpoint", + "question": "Count all stars" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.782, + "totalDuration": 5.446, + "tokens": { + "promptTokens": 4576, + "completionTokens": 609, + "totalTokens": 5185 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 repositories by stars\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by stars\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a2a54e810-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 repositories by stars\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 repositories by stars\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0ad9a2a54e810-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9afeda4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9b3b6cc0b2-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:41 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_02.pipe", + "question": { + "name": "pipe_02.pipe", + "content": "DESCRIPTION >\n Top 10 repositories by stars\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY repo_name ORDER BY stars DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 repositories by stars\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 repositories by stars\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9a2a54e810-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 repositories by stars\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by stars\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a2a54e810-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9afeda4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 repositories by stars\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9a2a54e810-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_02.pipe", + "question": { + "name": "pipe_02.pipe", + "content": "DESCRIPTION >\n Top 10 repositories by stars\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY repo_name ORDER BY stars DESC LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 repositories by stars" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 repositories by stars\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by stars\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a2a54e810-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9afeda4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_02.pipe", + "question": { + "name": "pipe_02.pipe", + "content": "DESCRIPTION >\n Top 10 repositories by stars\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY repo_name ORDER BY stars DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 repositories by stars\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 repositories by stars\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9a2a54e810-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 repositories by stars\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by stars\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a2a54e810-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 repositories by stars\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 repositories by stars\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0ad9a2a54e810-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9afeda4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9b3b6cc0b2-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:41 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_02.pipe", + "question": { + "name": "pipe_02.pipe", + "content": "DESCRIPTION >\n Top 10 repositories by stars\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY repo_name ORDER BY stars DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 repositories by stars\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 repositories by stars\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9a2a54e810-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 repositories by stars\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by stars\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a2a54e810-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9afeda4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n approx_stars,\n count() AS num_repos\nFROM (\n SELECT\n CASE\n WHEN count() < 10 THEN 1\n WHEN count() < 100 THEN 10\n WHEN count() < 1000 THEN 100\n WHEN count() < 10000 THEN 1000\n WHEN count() < 100000 THEN 10000\n WHEN count() < 1000000 THEN 100000\n WHEN count() < 10000000 THEN 1000000\n ELSE 10000000\n END AS approx_stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n) AS repo_buckets\nGROUP BY approx_stars\nORDER BY approx_stars ASC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "approx_stars": 1, + "num_repos": 537389 + }, + { + "approx_stars": 10, + "num_repos": 49995 + }, + { + "approx_stars": 100, + "num_repos": 8578 + }, + { + "approx_stars": 1000, + "num_repos": 902 + }, + { + "approx_stars": 10000, + "num_repos": 31 + } + ], + "meta": [ + { + "name": "approx_stars", + "type": "UInt32" + }, + { + "name": "num_repos", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.073449811, + "rows_read": 7321600, + "bytes_read": 35699881 + }, + "executionTime": 0.179, + "requestId": "01KA4B53HZXKT8E1E6E2P286T5", + "length": 191 + }, + "name": "pipe_03.pipe", + "question": { + "name": "pipe_03.pipe", + "content": "DESCRIPTION >\n For each power of 10 (1, 10, 100, 1000, etc.), count how many GitHub repositories have approximately that many stars. Order the results from smallest to largest star count\n\nNODE endpoint\nSQL >\n SELECT\n exp10(floor(log10(c))) AS stars,\n uniqExact(k)\n FROM\n (\n SELECT\n repo_name AS k,\n count() AS c\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY k\n )\n GROUP BY stars\n ORDER BY stars ASC\n\nTYPE endpoint", + "question": "For each power of 10 (1, 10, 100, 1000, etc.), count how many GitHub repositories have approximately that many stars. Order the results from smallest to largest star count" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.676, + "totalDuration": 51.384, + "tokens": { + "promptTokens": 4615, + "completionTokens": 7429, + "totalTokens": 12044 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n approx_stars,\n count() AS num_repos\nFROM (\n SELECT\n CASE\n WHEN count() < 10 THEN 1\n WHEN count() < 100 THEN 10\n WHEN count() < 1000 THEN 100\n WHEN count() < 10000 THEN 1000\n WHEN count() < 100000 THEN 10000\n WHEN count() < 1000000 THEN 100000\n WHEN count() < 10000000 THEN 1000000\n ELSE 10000000\n END AS approx_stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n) AS repo_buckets\nGROUP BY approx_stars\nORDER BY approx_stars ASC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "approx_stars": 1, + "num_repos": 537389 + }, + { + "approx_stars": 10, + "num_repos": 49995 + }, + { + "approx_stars": 100, + "num_repos": 8578 + }, + { + "approx_stars": 1000, + "num_repos": 902 + }, + { + "approx_stars": 10000, + "num_repos": 31 + } + ], + "meta": [ + { + "name": "approx_stars", + "type": "UInt32" + }, + { + "name": "num_repos", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.073449811, + "rows_read": 7321600, + "bytes_read": 35699881 + }, + "executionTime": 0.179, + "requestId": "01KA4B53HZXKT8E1E6E2P286T5", + "length": 191 + }, + "name": "pipe_03.pipe", + "question": { + "name": "pipe_03.pipe", + "content": "DESCRIPTION >\n For each power of 10 (1, 10, 100, 1000, etc.), count how many GitHub repositories have approximately that many stars. Order the results from smallest to largest star count\n\nNODE endpoint\nSQL >\n SELECT\n exp10(floor(log10(c))) AS stars,\n uniqExact(k)\n FROM\n (\n SELECT\n repo_name AS k,\n count() AS c\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY k\n )\n GROUP BY stars\n ORDER BY stars ASC\n\nTYPE endpoint", + "question": "For each power of 10 (1, 10, 100, 1000, etc.), count how many GitHub repositories have approximately that many stars. Order the results from smallest to largest star count" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.676, + "totalDuration": 51.384, + "tokens": { + "promptTokens": 4615, + "completionTokens": 7429, + "totalTokens": 12044 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"The total number of repositories on GitHub\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The total number of repositories on GitHub\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a1cde4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"The total number of repositories on GitHub\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"The total number of repositories on GitHub\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0ad9a1cde4fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9aba0cc0b2-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9b1d54e810-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:41 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_04.pipe", + "question": { + "name": "pipe_04.pipe", + "content": "DESCRIPTION >\n The total number of repositories on GitHub\n\nNODE endpoint\nSQL >\n SELECT uniqExact(repo_name) FROM github_events\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"The total number of repositories on GitHub\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"The total number of repositories on GitHub\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9a1cde4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"The total number of repositories on GitHub\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The total number of repositories on GitHub\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a1cde4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9aba0cc0b2-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"The total number of repositories on GitHub\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9a1cde4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_04.pipe", + "question": { + "name": "pipe_04.pipe", + "content": "DESCRIPTION >\n The total number of repositories on GitHub\n\nNODE endpoint\nSQL >\n SELECT uniqExact(repo_name) FROM github_events\n\nTYPE endpoint", + "question": "The total number of repositories on GitHub" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"The total number of repositories on GitHub\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The total number of repositories on GitHub\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a1cde4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9aba0cc0b2-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_04.pipe", + "question": { + "name": "pipe_04.pipe", + "content": "DESCRIPTION >\n The total number of repositories on GitHub\n\nNODE endpoint\nSQL >\n SELECT uniqExact(repo_name) FROM github_events\n\nTYPE endpoint", + "question": "I previously asked: \"The total number of repositories on GitHub\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"The total number of repositories on GitHub\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9a1cde4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"The total number of repositories on GitHub\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The total number of repositories on GitHub\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a1cde4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"The total number of repositories on GitHub\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"The total number of repositories on GitHub\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0ad9a1cde4fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9aba0cc0b2-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9b1d54e810-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:41 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_04.pipe", + "question": { + "name": "pipe_04.pipe", + "content": "DESCRIPTION >\n The total number of repositories on GitHub\n\nNODE endpoint\nSQL >\n SELECT uniqExact(repo_name) FROM github_events\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"The total number of repositories on GitHub\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"The total number of repositories on GitHub\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9a1cde4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"The total number of repositories on GitHub\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The total number of repositories on GitHub\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0ad9a1cde4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:05:40 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0ad9aba0cc0b2-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:05:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n YEAR(created_at) AS year,\n repo_name,\n count() AS stars\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND action = 'started'\n AND created_at >= '2015-01-01'\n AND repo_name != ''\nGROUP BY year, repo_name\nORDER BY year ASC, stars DESC\nLIMIT 10 BY year\nLIMIT 100\n", + "sqlResult": { + "success": true, + "data": [ + { + "year": 2016, + "repo_name": "yarnpkg/yarn", + "stars": 21518 + }, + { + "year": 2016, + "repo_name": "zeit/hyperterm", + "stars": 9086 + }, + { + "year": 2016, + "repo_name": "zeit/next.js", + "stars": 7877 + }, + { + "year": 2016, + "repo_name": "xitu/gold-miner", + "stars": 6022 + }, + { + "year": 2016, + "repo_name": "zenorocha/clipboard.js", + "stars": 5594 + }, + { + "year": 2016, + "repo_name": "yelouafi/redux-saga", + "stars": 5463 + }, + { + "year": 2016, + "repo_name": "yhatt/marp", + "stars": 5254 + }, + { + "year": 2016, + "repo_name": "zyedidia/micro", + "stars": 4952 + }, + { + "year": 2016, + "repo_name": "zeit/hyper", + "stars": 4926 + }, + { + "year": 2016, + "repo_name": "zxing/zxing", + "stars": 4890 + }, + { + "year": 2017, + "repo_name": "tensorflow/tensorflow", + "stars": 49278 + }, + { + "year": 2017, + "repo_name": "vuejs/vue", + "stars": 48185 + }, + { + "year": 2017, + "repo_name": "sindresorhus/awesome", + "stars": 29084 + }, + { + "year": 2017, + "repo_name": "thedaviddias/Front-End-Checklist", + "stars": 24745 + }, + { + "year": 2017, + "repo_name": "sdmg15/Best-websites-a-programmer-should-visit", + "stars": 21764 + }, + { + "year": 2017, + "repo_name": "twbs/bootstrap", + "stars": 21157 + }, + { + "year": 2017, + "repo_name": "toddmotto/public-apis", + "stars": 20881 + }, + { + "year": 2017, + "repo_name": "robbyrussell/oh-my-zsh", + "stars": 19325 + }, + { + "year": 2017, + "repo_name": "vuejs/awesome-vue", + "stars": 18499 + }, + { + "year": 2017, + "repo_name": "tipsy/github-profile-summary", + "stars": 17847 + } + ], + "meta": [ + { + "name": "year", + "type": "UInt16" + }, + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "stars", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.174845535, + "rows_read": 7321600, + "bytes_read": 72508059 + }, + "executionTime": 0.281, + "requestId": "01KA4B4DPWKCHRM9SND67GZQ5P", + "length": 1221 + }, + "name": "pipe_05.pipe", + "question": { + "name": "pipe_05.pipe", + "content": "DESCRIPTION >\n How has the list of top repositories changed over the years from 2015\n\nNODE endpoint\nSQL >\n SELECT\n year,\n lower(repo_name) AS repo,\n count()\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (year >= 2015)\n GROUP BY\n repo,\n toYear(created_at) AS year\n ORDER BY\n year ASC,\n count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "How has the list of top repositories changed over the years from 2015" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.588, + "totalDuration": 29.012, + "tokens": { + "promptTokens": 4588, + "completionTokens": 3581, + "totalTokens": 8169 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n YEAR(created_at) AS year,\n repo_name,\n count() AS stars\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND action = 'started'\n AND created_at >= '2015-01-01'\n AND repo_name != ''\nGROUP BY year, repo_name\nORDER BY year ASC, stars DESC\nLIMIT 10 BY year\nLIMIT 100\n", + "sqlResult": { + "success": true, + "data": [ + { + "year": 2016, + "repo_name": "yarnpkg/yarn", + "stars": 21518 + }, + { + "year": 2016, + "repo_name": "zeit/hyperterm", + "stars": 9086 + }, + { + "year": 2016, + "repo_name": "zeit/next.js", + "stars": 7877 + }, + { + "year": 2016, + "repo_name": "xitu/gold-miner", + "stars": 6022 + }, + { + "year": 2016, + "repo_name": "zenorocha/clipboard.js", + "stars": 5594 + }, + { + "year": 2016, + "repo_name": "yelouafi/redux-saga", + "stars": 5463 + }, + { + "year": 2016, + "repo_name": "yhatt/marp", + "stars": 5254 + }, + { + "year": 2016, + "repo_name": "zyedidia/micro", + "stars": 4952 + }, + { + "year": 2016, + "repo_name": "zeit/hyper", + "stars": 4926 + }, + { + "year": 2016, + "repo_name": "zxing/zxing", + "stars": 4890 + }, + { + "year": 2017, + "repo_name": "tensorflow/tensorflow", + "stars": 49278 + }, + { + "year": 2017, + "repo_name": "vuejs/vue", + "stars": 48185 + }, + { + "year": 2017, + "repo_name": "sindresorhus/awesome", + "stars": 29084 + }, + { + "year": 2017, + "repo_name": "thedaviddias/Front-End-Checklist", + "stars": 24745 + }, + { + "year": 2017, + "repo_name": "sdmg15/Best-websites-a-programmer-should-visit", + "stars": 21764 + }, + { + "year": 2017, + "repo_name": "twbs/bootstrap", + "stars": 21157 + }, + { + "year": 2017, + "repo_name": "toddmotto/public-apis", + "stars": 20881 + }, + { + "year": 2017, + "repo_name": "robbyrussell/oh-my-zsh", + "stars": 19325 + }, + { + "year": 2017, + "repo_name": "vuejs/awesome-vue", + "stars": 18499 + }, + { + "year": 2017, + "repo_name": "tipsy/github-profile-summary", + "stars": 17847 + } + ], + "meta": [ + { + "name": "year", + "type": "UInt16" + }, + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "stars", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.174845535, + "rows_read": 7321600, + "bytes_read": 72508059 + }, + "executionTime": 0.281, + "requestId": "01KA4B4DPWKCHRM9SND67GZQ5P", + "length": 1221 + }, + "name": "pipe_05.pipe", + "question": { + "name": "pipe_05.pipe", + "content": "DESCRIPTION >\n How has the list of top repositories changed over the years from 2015\n\nNODE endpoint\nSQL >\n SELECT\n year,\n lower(repo_name) AS repo,\n count()\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (year >= 2015)\n GROUP BY\n repo,\n toYear(created_at) AS year\n ORDER BY\n year ASC,\n count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "How has the list of top repositories changed over the years from 2015" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.588, + "totalDuration": 29.012, + "tokens": { + "promptTokens": 4588, + "completionTokens": 3581, + "totalTokens": 8169 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"How has the total number of stars changed over time by year?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"How has the total number of stars changed over time by year?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafe8e4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"How has the total number of stars changed over time by year?\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"How has the total number of stars changed over time by year?\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0aeeafe8e4fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeb5aba874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeebb8804fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_06.pipe", + "question": { + "name": "pipe_06.pipe", + "content": "DESCRIPTION >\n How has the total number of stars changed over time by year?\n\nNODE endpoint\nSQL >\n SELECT toYear(created_at) AS year, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY year ORDER BY year\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"How has the total number of stars changed over time by year?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"How has the total number of stars changed over time by year?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeafe8e4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"How has the total number of stars changed over time by year?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"How has the total number of stars changed over time by year?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafe8e4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb5aba874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"How has the total number of stars changed over time by year?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeafe8e4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_06.pipe", + "question": { + "name": "pipe_06.pipe", + "content": "DESCRIPTION >\n How has the total number of stars changed over time by year?\n\nNODE endpoint\nSQL >\n SELECT toYear(created_at) AS year, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY year ORDER BY year\n\nTYPE endpoint", + "question": "How has the total number of stars changed over time by year?" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"How has the total number of stars changed over time by year?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"How has the total number of stars changed over time by year?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafe8e4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb5aba874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_06.pipe", + "question": { + "name": "pipe_06.pipe", + "content": "DESCRIPTION >\n How has the total number of stars changed over time by year?\n\nNODE endpoint\nSQL >\n SELECT toYear(created_at) AS year, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY year ORDER BY year\n\nTYPE endpoint", + "question": "I previously asked: \"How has the total number of stars changed over time by year?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"How has the total number of stars changed over time by year?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeafe8e4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"How has the total number of stars changed over time by year?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"How has the total number of stars changed over time by year?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafe8e4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"How has the total number of stars changed over time by year?\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"How has the total number of stars changed over time by year?\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0aeeafe8e4fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeb5aba874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeebb8804fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_06.pipe", + "question": { + "name": "pipe_06.pipe", + "content": "DESCRIPTION >\n How has the total number of stars changed over time by year?\n\nNODE endpoint\nSQL >\n SELECT toYear(created_at) AS year, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY year ORDER BY year\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"How has the total number of stars changed over time by year?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"How has the total number of stars changed over time by year?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeafe8e4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"How has the total number of stars changed over time by year?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"How has the total number of stars changed over time by year?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafe8e4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb5aba874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "SELECT\n actor_login,\n count() AS stars_given\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY actor_login\nORDER BY stars_given DESC\nLIMIT 10", + "sqlResult": { + "success": true, + "data": [ + { + "actor_login": "baslr", + "stars_given": 11953 + }, + { + "actor_login": "korolr", + "stars_given": 6428 + }, + { + "actor_login": "roscopecoltran", + "stars_given": 3625 + }, + { + "actor_login": "AlexxNica", + "stars_given": 2637 + }, + { + "actor_login": "maoabc1818", + "stars_given": 2348 + }, + { + "actor_login": "fly51fly", + "stars_given": 2171 + }, + { + "actor_login": "jenniemanphonsy", + "stars_given": 1930 + }, + { + "actor_login": "pranavlathigara", + "stars_given": 1885 + }, + { + "actor_login": "aidan-n", + "stars_given": 1882 + }, + { + "actor_login": "bestwpw", + "stars_given": 1740 + } + ], + "meta": [ + { + "name": "actor_login", + "type": "LowCardinality(String)" + }, + { + "name": "stars_given", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.190856871, + "rows_read": 7321600, + "bytes_read": 121887984 + }, + "executionTime": 0.293, + "requestId": "01KA4B5B2NTN7CQVVQC72NPS7V", + "length": 478 + }, + "name": "pipe_07.pipe", + "question": { + "name": "pipe_07.pipe", + "content": "DESCRIPTION >\n Who are top 10 people giving stars?\n\nNODE endpoint\nSQL >\n SELECT actor_login, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY actor_login ORDER BY stars DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Who are top 10 people giving stars?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Who are top 10 people giving stars?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeaf9f514ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Who are top 10 people giving stars?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Who are top 10 people giving stars?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeaf9f514ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb8c4beb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 1.59, + "totalDuration": 4.87, + "tokens": { + "promptTokens": 19646, + "completionTokens": 359, + "totalTokens": 20005 + } + }, + "error": null, + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Who are top 10 people giving stars?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeaf9f514ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_07.pipe", + "question": { + "name": "pipe_07.pipe", + "content": "DESCRIPTION >\n Who are top 10 people giving stars?\n\nNODE endpoint\nSQL >\n SELECT actor_login, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY actor_login ORDER BY stars DESC LIMIT 10\n\nTYPE endpoint", + "question": "Who are top 10 people giving stars?" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Who are top 10 people giving stars?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Who are top 10 people giving stars?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeaf9f514ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb8c4beb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_07.pipe", + "question": { + "name": "pipe_07.pipe", + "content": "DESCRIPTION >\n Who are top 10 people giving stars?\n\nNODE endpoint\nSQL >\n SELECT actor_login, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY actor_login ORDER BY stars DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Who are top 10 people giving stars?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Who are top 10 people giving stars?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeaf9f514ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": "SELECT\n actor_login,\n count() AS stars_given\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY actor_login\nORDER BY stars_given DESC\nLIMIT 10", + "sqlResult": { + "success": true, + "data": [ + { + "actor_login": "baslr", + "stars_given": 11953 + }, + { + "actor_login": "korolr", + "stars_given": 6428 + }, + { + "actor_login": "roscopecoltran", + "stars_given": 3625 + }, + { + "actor_login": "AlexxNica", + "stars_given": 2637 + }, + { + "actor_login": "maoabc1818", + "stars_given": 2348 + }, + { + "actor_login": "fly51fly", + "stars_given": 2171 + }, + { + "actor_login": "jenniemanphonsy", + "stars_given": 1930 + }, + { + "actor_login": "pranavlathigara", + "stars_given": 1885 + }, + { + "actor_login": "aidan-n", + "stars_given": 1882 + }, + { + "actor_login": "bestwpw", + "stars_given": 1740 + } + ], + "meta": [ + { + "name": "actor_login", + "type": "LowCardinality(String)" + }, + { + "name": "stars_given", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.190856871, + "rows_read": 7321600, + "bytes_read": 121887984 + }, + "executionTime": 0.293, + "requestId": "01KA4B5B2NTN7CQVVQC72NPS7V", + "length": 478 + }, + "name": "pipe_07.pipe", + "question": { + "name": "pipe_07.pipe", + "content": "DESCRIPTION >\n Who are top 10 people giving stars?\n\nNODE endpoint\nSQL >\n SELECT actor_login, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY actor_login ORDER BY stars DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Who are top 10 people giving stars?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Who are top 10 people giving stars?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeaf9f514ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Who are top 10 people giving stars?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Who are top 10 people giving stars?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeaf9f514ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb8c4beb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 1.59, + "totalDuration": 4.87, + "tokens": { + "promptTokens": 19646, + "completionTokens": 359, + "totalTokens": 20005 + } + }, + "error": null + } + ] + }, + { + "sql": "\nSELECT \n e2.repo_name AS repo_name,\n count() AS stars_count\nFROM github_events AS e1\nINNER JOIN github_events AS e2 ON e1.actor_login = e2.actor_login\nWHERE \n e1.event_type = 'WatchEvent' \n AND e1.action = 'started' \n AND e1.repo_name = 'tensorflow/tensorflow'\n AND e2.event_type = 'WatchEvent' \n AND e2.action = 'started' \n AND e2.repo_name != 'tensorflow/tensorflow'\nGROUP BY e2.repo_name\nORDER BY stars_count DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "torvalds/linux", + "stars_count": 1466783 + }, + { + "repo_name": "sindresorhus/awesome", + "stars_count": 1466492 + }, + { + "repo_name": "twbs/bootstrap", + "stars_count": 1465293 + }, + { + "repo_name": "rails/rails", + "stars_count": 1463707 + }, + { + "repo_name": "vuejs/vue", + "stars_count": 1463697 + }, + { + "repo_name": "socketio/socket.io", + "stars_count": 1460592 + }, + { + "repo_name": "rust-lang/rust", + "stars_count": 1460582 + }, + { + "repo_name": "webpack/webpack", + "stars_count": 1458478 + }, + { + "repo_name": "robbyrussell/oh-my-zsh", + "stars_count": 659503 + }, + { + "repo_name": "vhf/free-programming-books", + "stars_count": 656202 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "stars_count", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.369744073, + "rows_read": 7354368, + "bytes_read": 157001146 + }, + "executionTime": 0.475, + "requestId": "01KA4B5MDDVSH19KWZBYYMM986", + "length": 552 + }, + "name": "pipe_08.pipe", + "question": { + "name": "pipe_08.pipe", + "content": "DESCRIPTION >\n what are the top 10 repositories sorted by the number of stars from people who starred the tensorflow/tensorflow repository?\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS stars\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (repo_name IN ('tensorflow/tensorflow'))\n )) AND (repo_name NOT IN ('tensorflow/tensorflow'))\n GROUP BY repo_name\n ORDER BY stars DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "what are the top 10 repositories sorted by the number of stars from people who starred the tensorflow/tensorflow repository?" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.832, + "totalDuration": 14.578, + "tokens": { + "promptTokens": 4595, + "completionTokens": 1779, + "totalTokens": 6374 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT \n e2.repo_name AS repo_name,\n count() AS stars_count\nFROM github_events AS e1\nINNER JOIN github_events AS e2 ON e1.actor_login = e2.actor_login\nWHERE \n e1.event_type = 'WatchEvent' \n AND e1.action = 'started' \n AND e1.repo_name = 'tensorflow/tensorflow'\n AND e2.event_type = 'WatchEvent' \n AND e2.action = 'started' \n AND e2.repo_name != 'tensorflow/tensorflow'\nGROUP BY e2.repo_name\nORDER BY stars_count DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "torvalds/linux", + "stars_count": 1466783 + }, + { + "repo_name": "sindresorhus/awesome", + "stars_count": 1466492 + }, + { + "repo_name": "twbs/bootstrap", + "stars_count": 1465293 + }, + { + "repo_name": "rails/rails", + "stars_count": 1463707 + }, + { + "repo_name": "vuejs/vue", + "stars_count": 1463697 + }, + { + "repo_name": "socketio/socket.io", + "stars_count": 1460592 + }, + { + "repo_name": "rust-lang/rust", + "stars_count": 1460582 + }, + { + "repo_name": "webpack/webpack", + "stars_count": 1458478 + }, + { + "repo_name": "robbyrussell/oh-my-zsh", + "stars_count": 659503 + }, + { + "repo_name": "vhf/free-programming-books", + "stars_count": 656202 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "stars_count", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.369744073, + "rows_read": 7354368, + "bytes_read": 157001146 + }, + "executionTime": 0.475, + "requestId": "01KA4B5MDDVSH19KWZBYYMM986", + "length": 552 + }, + "name": "pipe_08.pipe", + "question": { + "name": "pipe_08.pipe", + "content": "DESCRIPTION >\n what are the top 10 repositories sorted by the number of stars from people who starred the tensorflow/tensorflow repository?\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS stars\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (repo_name IN ('tensorflow/tensorflow'))\n )) AND (repo_name NOT IN ('tensorflow/tensorflow'))\n GROUP BY repo_name\n ORDER BY stars DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "what are the top 10 repositories sorted by the number of stars from people who starred the tensorflow/tensorflow repository?" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.832, + "totalDuration": 14.578, + "tokens": { + "promptTokens": 4595, + "completionTokens": 1779, + "totalTokens": 6374 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafaa1eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0aeeafaa1eb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeb5f944fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeebac4414ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_09.pipe", + "question": { + "name": "pipe_09.pipe", + "content": "DESCRIPTION >\n Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\n\nNODE endpoint\nSQL >\n WITH repo_name IN\n (\n SELECT repo_name\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN ('javisantana'))\n ) AS is_my_repo\n SELECT\n actor_login,\n sum(is_my_repo) AS stars_my,\n sum(NOT is_my_repo) AS stars_other,\n round(stars_my / (stars_my + stars_other), 3) AS ratio\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY actor_login\n ORDER BY ratio DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeafaa1eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafaa1eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb5f944fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeafaa1eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_09.pipe", + "question": { + "name": "pipe_09.pipe", + "content": "DESCRIPTION >\n Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\n\nNODE endpoint\nSQL >\n WITH repo_name IN\n (\n SELECT repo_name\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN ('javisantana'))\n ) AS is_my_repo\n SELECT\n actor_login,\n sum(is_my_repo) AS stars_my,\n sum(NOT is_my_repo) AS stars_other,\n round(stars_my / (stars_my + stars_other), 3) AS ratio\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY actor_login\n ORDER BY ratio DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafaa1eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb5f944fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_09.pipe", + "question": { + "name": "pipe_09.pipe", + "content": "DESCRIPTION >\n Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\n\nNODE endpoint\nSQL >\n WITH repo_name IN\n (\n SELECT repo_name\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN ('javisantana'))\n ) AS is_my_repo\n SELECT\n actor_login,\n sum(is_my_repo) AS stars_my,\n sum(NOT is_my_repo) AS stars_other,\n round(stars_my / (stars_my + stars_other), 3) AS ratio\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY actor_login\n ORDER BY ratio DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeafaa1eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafaa1eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0aeeafaa1eb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeb5f944fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeebac4414ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_09.pipe", + "question": { + "name": "pipe_09.pipe", + "content": "DESCRIPTION >\n Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\n\nNODE endpoint\nSQL >\n WITH repo_name IN\n (\n SELECT repo_name\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN ('javisantana'))\n ) AS is_my_repo\n SELECT\n actor_login,\n sum(is_my_repo) AS stars_my,\n sum(NOT is_my_repo) AS stars_other,\n round(stars_my / (stars_my + stars_other), 3) AS ratio\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY actor_login\n ORDER BY ratio DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeafaa1eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Find the top 10 GitHub users who have the highest proportion of their stars given to repositories owned by 'javisantana' compared to all other repositories they've starred. Show each user's name, the number of stars they gave to javisantana's repos, the number of stars they gave to other repos, and the ratio of javisantana stars to total stars.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0aeeafaa1eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:06:34 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0aeeb5f944fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:06:34 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n pr.repo_name,\n countDistinct(pr.actor_login) AS unique_tf_contributors\nFROM github_events AS pr\nINNER JOIN github_events AS tf\nON pr.actor_login = tf.actor_login\nWHERE pr.event_type = 'PullRequestEvent'\n AND pr.action = 'opened'\n AND pr.repo_name != 'tensorflow/tensorflow'\n AND tf.event_type = 'PullRequestEvent'\n AND tf.action = 'opened'\n AND tf.repo_name = 'tensorflow/tensorflow'\nGROUP BY pr.repo_name\nORDER BY unique_tf_contributors DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "tensorflow/models", + "unique_tf_contributors": 36 + }, + { + "repo_name": "fchollet/keras", + "unique_tf_contributors": 19 + }, + { + "repo_name": "pytorch/pytorch", + "unique_tf_contributors": 19 + }, + { + "repo_name": "scikit-learn/scikit-learn", + "unique_tf_contributors": 15 + }, + { + "repo_name": "tflearn/tflearn", + "unique_tf_contributors": 13 + }, + { + "repo_name": "tensorflow/skflow", + "unique_tf_contributors": 10 + }, + { + "repo_name": "tensorflow/serving", + "unique_tf_contributors": 9 + }, + { + "repo_name": "google/protobuf", + "unique_tf_contributors": 8 + }, + { + "repo_name": "openai/gym", + "unique_tf_contributors": 7 + }, + { + "repo_name": "numpy/numpy", + "unique_tf_contributors": 6 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "unique_tf_contributors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.120613084, + "rows_read": 18451865, + "bytes_read": 143024277 + }, + "executionTime": 0.224, + "requestId": "01KA4B5XXZ89XF5EGD4P0SR0C6", + "length": 604 + }, + "name": "pipe_10.pipe", + "question": { + "name": "pipe_10.pipe", + "content": "DESCRIPTION >\n Find the top 10 non-TensorFlow repositories that received the most pull requests from TensorFlow contributors, ranked by the number of unique contributors.\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n uniqExact(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened') AND (repo_name like '%tensorflow%')\n )) AND (repo_name NOT ILIKE '%tensorflow%')\n GROUP BY repo_name\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Find the top 10 non-TensorFlow repositories that received the most pull requests from TensorFlow contributors, ranked by the number of unique contributors." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.67, + "totalDuration": 24.322, + "tokens": { + "promptTokens": 4602, + "completionTokens": 3028, + "totalTokens": 7630 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n pr.repo_name,\n countDistinct(pr.actor_login) AS unique_tf_contributors\nFROM github_events AS pr\nINNER JOIN github_events AS tf\nON pr.actor_login = tf.actor_login\nWHERE pr.event_type = 'PullRequestEvent'\n AND pr.action = 'opened'\n AND pr.repo_name != 'tensorflow/tensorflow'\n AND tf.event_type = 'PullRequestEvent'\n AND tf.action = 'opened'\n AND tf.repo_name = 'tensorflow/tensorflow'\nGROUP BY pr.repo_name\nORDER BY unique_tf_contributors DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "tensorflow/models", + "unique_tf_contributors": 36 + }, + { + "repo_name": "fchollet/keras", + "unique_tf_contributors": 19 + }, + { + "repo_name": "pytorch/pytorch", + "unique_tf_contributors": 19 + }, + { + "repo_name": "scikit-learn/scikit-learn", + "unique_tf_contributors": 15 + }, + { + "repo_name": "tflearn/tflearn", + "unique_tf_contributors": 13 + }, + { + "repo_name": "tensorflow/skflow", + "unique_tf_contributors": 10 + }, + { + "repo_name": "tensorflow/serving", + "unique_tf_contributors": 9 + }, + { + "repo_name": "google/protobuf", + "unique_tf_contributors": 8 + }, + { + "repo_name": "openai/gym", + "unique_tf_contributors": 7 + }, + { + "repo_name": "numpy/numpy", + "unique_tf_contributors": 6 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "unique_tf_contributors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.120613084, + "rows_read": 18451865, + "bytes_read": 143024277 + }, + "executionTime": 0.224, + "requestId": "01KA4B5XXZ89XF5EGD4P0SR0C6", + "length": 604 + }, + "name": "pipe_10.pipe", + "question": { + "name": "pipe_10.pipe", + "content": "DESCRIPTION >\n Find the top 10 non-TensorFlow repositories that received the most pull requests from TensorFlow contributors, ranked by the number of unique contributors.\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n uniqExact(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened') AND (repo_name like '%tensorflow%')\n )) AND (repo_name NOT ILIKE '%tensorflow%')\n GROUP BY repo_name\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Find the top 10 non-TensorFlow repositories that received the most pull requests from TensorFlow contributors, ranked by the number of unique contributors." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.67, + "totalDuration": 24.322, + "tokens": { + "promptTokens": 4602, + "completionTokens": 3028, + "totalTokens": 7630 + } + }, + "error": null + } + ] + }, + { + "sql": "SELECT\n repo_name,\n count(*) AS issue_count\nFROM github_events\nWHERE event_type = 'IssuesEvent'\n AND action = 'opened'\n AND repo_name != 'tensorflow/tensorflow'\n AND actor_login IN (\n SELECT actor_login\n FROM github_events\n WHERE event_type = 'IssuesEvent'\n AND action = 'opened'\n AND repo_name = 'tensorflow/tensorflow'\n GROUP BY actor_login\n )\nGROUP BY repo_name\nORDER BY issue_count DESC\nLIMIT 10", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "pytorch/pytorch", + "issue_count": 1071 + }, + { + "repo_name": "albertz/openlierox", + "issue_count": 736 + }, + { + "repo_name": "stellargraph/stellargraph", + "issue_count": 656 + }, + { + "repo_name": "tensorflow/addons", + "issue_count": 472 + }, + { + "repo_name": "tensorflow/models", + "issue_count": 450 + }, + { + "repo_name": "tensorflow/datasets", + "issue_count": 278 + }, + { + "repo_name": "ray-project/ray", + "issue_count": 244 + }, + { + "repo_name": "tensorflow/probability", + "issue_count": 220 + }, + { + "repo_name": "opencv/opencv", + "issue_count": 214 + }, + { + "repo_name": "rocm-arch/rocm-arch", + "issue_count": 198 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "issue_count", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.122960471, + "rows_read": 15322252, + "bytes_read": 89392491 + }, + "executionTime": 0.226, + "requestId": "01KA4B77KPH87SEVBTMGHFNAEJ", + "length": 532 + }, + "name": "pipe_11.pipe", + "question": { + "name": "pipe_11.pipe", + "content": "DESCRIPTION >\n top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author.\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS prs,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'IssuesEvent') AND (action = 'opened') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'IssuesEvent') AND (action = 'opened') AND (repo_name IN ('tensorflow/tensorflow'))\n )) AND (repo_name NOT ILIKE '%tensorflow%')\n GROUP BY repo_name\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af940c474fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.808, + "totalDuration": 39.909, + "tokens": { + "promptTokens": 9597, + "completionTokens": 5439, + "totalTokens": 15036 + } + }, + "error": null, + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af940c474fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_11.pipe", + "question": { + "name": "pipe_11.pipe", + "content": "DESCRIPTION >\n top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author.\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS prs,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'IssuesEvent') AND (action = 'opened') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'IssuesEvent') AND (action = 'opened') AND (repo_name IN ('tensorflow/tensorflow'))\n )) AND (repo_name NOT ILIKE '%tensorflow%')\n GROUP BY repo_name\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": "SELECT\n repo_name,\n count(*) AS issue_count\nFROM github_events\nWHERE event_type = 'IssuesEvent'\n AND action = 'opened'\n AND repo_name != 'tensorflow/tensorflow'\n AND actor_login IN (\n SELECT actor_login\n FROM github_events\n WHERE event_type = 'IssuesEvent'\n AND action = 'opened'\n AND repo_name = 'tensorflow/tensorflow'\n GROUP BY actor_login\n )\nGROUP BY repo_name\nORDER BY issue_count DESC\nLIMIT 10", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "pytorch/pytorch", + "issue_count": 1071 + }, + { + "repo_name": "albertz/openlierox", + "issue_count": 736 + }, + { + "repo_name": "stellargraph/stellargraph", + "issue_count": 656 + }, + { + "repo_name": "tensorflow/addons", + "issue_count": 472 + }, + { + "repo_name": "tensorflow/models", + "issue_count": 450 + }, + { + "repo_name": "tensorflow/datasets", + "issue_count": 278 + }, + { + "repo_name": "ray-project/ray", + "issue_count": 244 + }, + { + "repo_name": "tensorflow/probability", + "issue_count": 220 + }, + { + "repo_name": "opencv/opencv", + "issue_count": 214 + }, + { + "repo_name": "rocm-arch/rocm-arch", + "issue_count": 198 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "issue_count", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.122960471, + "rows_read": 15322252, + "bytes_read": 89392491 + }, + "executionTime": 0.226, + "requestId": "01KA4B77KPH87SEVBTMGHFNAEJ", + "length": 532 + }, + "name": "pipe_11.pipe", + "question": { + "name": "pipe_11.pipe", + "content": "DESCRIPTION >\n top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author.\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS prs,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'IssuesEvent') AND (action = 'opened') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'IssuesEvent') AND (action = 'opened') AND (repo_name IN ('tensorflow/tensorflow'))\n )) AND (repo_name NOT ILIKE '%tensorflow%')\n GROUP BY repo_name\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 repositories with most issues from users who also opened issues in tensorflow/tensorflow, rank by author.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af940c474fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.808, + "totalDuration": 39.909, + "tokens": { + "promptTokens": 9597, + "completionTokens": 5439, + "totalTokens": 15036 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af940e8aeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0af940e8aeb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af944cda4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af947a4b14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_12.pipe", + "question": { + "name": "pipe_12.pipe", + "content": "DESCRIPTION >\n top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n toDate(created_at) AS day,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY\n repo_name,\n day\n ORDER BY count() DESC\n LIMIT 1 BY repo_name\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af940e8aeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af940e8aeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af944cda4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af940e8aeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_12.pipe", + "question": { + "name": "pipe_12.pipe", + "content": "DESCRIPTION >\n top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n toDate(created_at) AS day,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY\n repo_name,\n day\n ORDER BY count() DESC\n LIMIT 1 BY repo_name\n LIMIT 10\n\nTYPE endpoint", + "question": "top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af940e8aeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af944cda4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_12.pipe", + "question": { + "name": "pipe_12.pipe", + "content": "DESCRIPTION >\n top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n toDate(created_at) AS day,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY\n repo_name,\n day\n ORDER BY count() DESC\n LIMIT 1 BY repo_name\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af940e8aeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af940e8aeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0af940e8aeb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af944cda4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af947a4b14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_12.pipe", + "question": { + "name": "pipe_12.pipe", + "content": "DESCRIPTION >\n top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n toDate(created_at) AS day,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY\n repo_name,\n day\n ORDER BY count() DESC\n LIMIT 1 BY repo_name\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af940e8aeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top uniq 10 Repositories with the most stars over one full day at any instant. Limit to 10 results do not repeat repository names\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af940e8aeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af944cda4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\\\"\\n\\nYou generated this SQL query:\\n```sql\\n\\nSELECT\\n repo_name,\\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\\n sum(if(YEAR(created_at)\\n```\\n\\nBut it resulted in this error:\\n```\\n{\\\"error\\\": \\\"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\\\", \\\"documentation\\\": \\\"https://docs.tinybird.co/query/query-parameters.html\\\"}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\n\\\\nSELECT\\\\n repo_name,\\\\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\\\\n sum(if(YEAR(created_at)\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\n{\\\\\\\"error\\\\\\\": \\\\\\\"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\\\\\\\", \\\\\\\"documentation\\\\\\\": \\\\\\\"https://docs.tinybird.co/query/query-parameters.html\\\\\\\"}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b0eaadff14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:56 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b0eb6b284fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:56 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_13.pipe", + "question": { + "name": "pipe_13.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\n\nNODE endpoint\nSQL >\n WITH toYear(created_at) AS year\n SELECT\n repo_name,\n sum(year = 2017) AS stars2017,\n sum(year = 2016) AS stars2016,\n round((stars2017 - stars2016) / stars2016 * 100, 2) as yoy\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING stars2016 >= 1\n ORDER BY yoy DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\"\n\nYou generated this SQL query:\n```sql\n\nSELECT\n repo_name,\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\n sum(if(YEAR(created_at)\n```\n\nBut it resulted in this error:\n```\n{\"error\": \"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\", \"documentation\": \"https://docs.tinybird.co/query/query-parameters.html\"}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\\\"\\n\\nYou generated this SQL query:\\n```sql\\n\\nSELECT\\n repo_name,\\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\\n sum(if(YEAR(created_at)\\n```\\n\\nBut it resulted in this error:\\n```\\n{\\\"error\\\": \\\"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\\\", \\\"documentation\\\": \\\"https://docs.tinybird.co/query/query-parameters.html\\\"}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b0eaadff14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:56 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": "\nSELECT\n repo_name,\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\n sum(if(YEAR(created_at)", + "sqlResult": { + "success": false, + "data": [], + "executionTime": 0.096, + "requestId": "01KA4B7KJZNCPN8YEZ8ZYP6F98", + "error": "{\"error\": \"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\", \"documentation\": \"https://docs.tinybird.co/query/query-parameters.html\"}", + "length": 2 + }, + "name": "pipe_13.pipe", + "question": { + "name": "pipe_13.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\n\nNODE endpoint\nSQL >\n WITH toYear(created_at) AS year\n SELECT\n repo_name,\n sum(year = 2017) AS stars2017,\n sum(year = 2016) AS stars2016,\n round((stars2017 - stars2016) / stars2016 * 100, 2) as yoy\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING stars2016 >= 1\n ORDER BY yoy DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.604, + "totalDuration": 52.215, + "tokens": { + "promptTokens": 4596, + "completionTokens": 6141, + "totalTokens": 10737 + } + }, + "error": null + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\\\"\\n\\nYou generated this SQL query:\\n```sql\\n\\nSELECT\\n repo_name,\\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\\n sum(if(YEAR(created_at)\\n```\\n\\nBut it resulted in this error:\\n```\\n{\\\"error\\\": \\\"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\\\", \\\"documentation\\\": \\\"https://docs.tinybird.co/query/query-parameters.html\\\"}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b0eaadff14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:56 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_13.pipe", + "question": { + "name": "pipe_13.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\n\nNODE endpoint\nSQL >\n WITH toYear(created_at) AS year\n SELECT\n repo_name,\n sum(year = 2017) AS stars2017,\n sum(year = 2016) AS stars2016,\n round((stars2017 - stars2016) / stars2016 * 100, 2) as yoy\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING stars2016 >= 1\n ORDER BY yoy DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\"\n\nYou generated this SQL query:\n```sql\n\nSELECT\n repo_name,\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\n sum(if(YEAR(created_at)\n```\n\nBut it resulted in this error:\n```\n{\"error\": \"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\", \"documentation\": \"https://docs.tinybird.co/query/query-parameters.html\"}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\\\"\\n\\nYou generated this SQL query:\\n```sql\\n\\nSELECT\\n repo_name,\\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\\n sum(if(YEAR(created_at)\\n```\\n\\nBut it resulted in this error:\\n```\\n{\\\"error\\\": \\\"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\\\", \\\"documentation\\\": \\\"https://docs.tinybird.co/query/query-parameters.html\\\"}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\n\\\\nSELECT\\\\n repo_name,\\\\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\\\\n sum(if(YEAR(created_at)\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\n{\\\\\\\"error\\\\\\\": \\\\\\\"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\\\\\\\", \\\\\\\"documentation\\\\\\\": \\\\\\\"https://docs.tinybird.co/query/query-parameters.html\\\\\\\"}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b0eaadff14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:56 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b0eb6b284fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:56 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_13.pipe", + "question": { + "name": "pipe_13.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\n\nNODE endpoint\nSQL >\n WITH toYear(created_at) AS year\n SELECT\n repo_name,\n sum(year = 2017) AS stars2017,\n sum(year = 2016) AS stars2016,\n round((stars2017 - stars2016) / stars2016 * 100, 2) as yoy\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING stars2016 >= 1\n ORDER BY yoy DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\"\n\nYou generated this SQL query:\n```sql\n\nSELECT\n repo_name,\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\n sum(if(YEAR(created_at)\n```\n\nBut it resulted in this error:\n```\n{\"error\": \"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\", \"documentation\": \"https://docs.tinybird.co/query/query-parameters.html\"}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the highest growth YoY 2016 and 2017 starting from 1 star\\\"\\n\\nYou generated this SQL query:\\n```sql\\n\\nSELECT\\n repo_name,\\n sum(if(YEAR(created_at) = 2016, 1, 0)) AS stars_2016,\\n sum(if(YEAR(created_at)\\n```\\n\\nBut it resulted in this error:\\n```\\n{\\\"error\\\": \\\"DB::Exception: Syntax error: failed at position 82 ('(') (line 4, col 6): (if(YEAR(created_at) FORMAT JSON. Unmatched parentheses: ((\\\", \\\"documentation\\\": \\\"https://docs.tinybird.co/query/query-parameters.html\\\"}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b0eaadff14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:56 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af94095214ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0af94095214ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af946fabeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af94adaf4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_14.pipe", + "question": { + "name": "pipe_14.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\n\nNODE endpoint\nSQL >\n WITH toYear(created_at) AS year\n SELECT\n repo_name,\n sum(year = 2017) AS stars2017,\n sum(year = 2016) AS stars2016,\n round((stars2017 - stars2016) / stars2016 * 100, 2) as yoy\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING (stars2017 >= 1)\n ORDER BY yoy ASC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af94095214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af94095214ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af946fabeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af94095214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_14.pipe", + "question": { + "name": "pipe_14.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\n\nNODE endpoint\nSQL >\n WITH toYear(created_at) AS year\n SELECT\n repo_name,\n sum(year = 2017) AS stars2017,\n sum(year = 2016) AS stars2016,\n round((stars2017 - stars2016) / stars2016 * 100, 2) as yoy\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING (stars2017 >= 1)\n ORDER BY yoy ASC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af94095214ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af946fabeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_14.pipe", + "question": { + "name": "pipe_14.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\n\nNODE endpoint\nSQL >\n WITH toYear(created_at) AS year\n SELECT\n repo_name,\n sum(year = 2017) AS stars2017,\n sum(year = 2016) AS stars2016,\n round((stars2017 - stars2016) / stars2016 * 100, 2) as yoy\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING (stars2017 >= 1)\n ORDER BY yoy ASC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af94095214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af94095214ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0af94095214ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af946fabeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af94adaf4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_14.pipe", + "question": { + "name": "pipe_14.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\n\nNODE endpoint\nSQL >\n WITH toYear(created_at) AS year\n SELECT\n repo_name,\n sum(year = 2017) AS stars2017,\n sum(year = 2016) AS stars2016,\n round((stars2017 - stars2016) / stars2016 * 100, 2) as yoy\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING (stars2017 >= 1)\n ORDER BY yoy ASC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af94095214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the worst stagnation in 2017 vs 2016. Repos with at least one star in 2017\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0af94095214ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:07:01 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0af946fabeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:07:01 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n repo_name,\n count() AS total_stars,\n STDDEV_POP(CAST(created_at AS UInt32)) AS std_ts,\n CAST(max(created_at) AS UInt32) - CAST(min(created_at) AS UInt32) AS span_seconds,\n STDDEV_POP(CAST(created_at AS UInt32)) * 3.46410161514 / (CAST(max(created_at) AS UInt32) - CAST(min(created_at) AS UInt32) + 1e-9) AS steadiness_ratio\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND created_at >= now() - INTERVAL 1 YEAR\nGROUP BY repo_name\nHAVING total_stars >= 100\n AND span_seconds > 0\nORDER BY steadiness_ratio DESC, total_stars DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "total_stars", + "type": "UInt64" + }, + { + "name": "std_ts", + "type": "Float64" + }, + { + "name": "span_seconds", + "type": "Int64" + }, + { + "name": "steadiness_ratio", + "type": "Float64" + } + ], + "statistics": { + "elapsed": 0.005841623, + "rows_read": 0, + "bytes_read": 0 + }, + "executionTime": 0.107, + "requestId": "01KA4B9M16X8H8CRATZHJ7CCYK", + "length": 2 + }, + "name": "pipe_15.pipe", + "question": { + "name": "pipe_15.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most steady star growth rate over time\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n max(stars) AS daily_stars,\n sum(stars) AS total_stars,\n total_stars / daily_stars AS rate\n FROM\n (\n SELECT\n repo_name,\n toDate(created_at) AS day,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY\n repo_name,\n day\n )\n GROUP BY repo_name\n ORDER BY rate DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the most steady star growth rate over time\"\n\nYou generated this SQL query:\n```sql\n\nSELECT\n repo_name,\n count() AS total_stars,\n STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts,\n TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds,\n STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514 / (TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) + 1e-9) AS steadiness_ratio\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND created_at >= now() - INTERVAL 1 YEAR\nGROUP BY repo_name\nHAVING total_stars >= 100\n AND TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) > 0\nORDER BY steadiness_ratio DESC, total_stars DESC\nLIMIT 10\n\n```\n\nBut it resulted in this error:\n```\n{\"error\": \"[Error] A value of illegal type was provided as 1st argument 'time' to function 'parseDateTime'. Expected: String, got: DateTime: In scope SELECT repo_name, count() AS total_stars, STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts, TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds, (STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514) / ((TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at))) + 1e-9) AS steadiness_ratio FROM github_llm_bench.github_events A\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most steady star growth rate over time\\\"\\n\\nYou generated this SQL query:\\n```sql\\n\\nSELECT\\n repo_name,\\n count() AS total_stars,\\n STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts,\\n TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds,\\n STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514 / (TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) + 1e-9) AS steadiness_ratio\\nFROM github_events\\nWHERE event_type = 'WatchEvent'\\n AND created_at >= now() - INTERVAL 1 YEAR\\nGROUP BY repo_name\\nHAVING total_stars >= 100\\n AND TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) > 0\\nORDER BY steadiness_ratio DESC, total_stars DESC\\nLIMIT 10\\n\\n```\\n\\nBut it resulted in this error:\\n```\\n{\\\"error\\\": \\\"[Error] A value of illegal type was provided as 1st argument 'time' to function 'parseDateTime'. Expected: String, got: DateTime: In scope SELECT repo_name, count() AS total_stars, STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts, TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds, (STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514) / ((TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at))) + 1e-9) AS steadiness_ratio FROM github_llm_bench.github_events A\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b1a369ac14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:08:26 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.658, + "totalDuration": 33.778, + "tokens": { + "promptTokens": 10349, + "completionTokens": 4459, + "totalTokens": 14808 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n repo_name,\n count() AS total_stars,\n STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts,\n TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds,\n STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514 / (TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) + 1e-9) AS steadiness_ratio\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND created_at >= now() - INTERVAL 1 YEAR\nGROUP BY repo_name\nHAVING total_stars >= 100\n AND TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) > 0\nORDER BY steadiness_ratio DESC, total_stars DESC\nLIMIT 10\n", + "sqlResult": { + "success": false, + "data": [], + "executionTime": 0.102, + "requestId": "01KA4B8GER89TYP8VWNQMZX1DK", + "error": "{\"error\": \"[Error] A value of illegal type was provided as 1st argument 'time' to function 'parseDateTime'. Expected: String, got: DateTime: In scope SELECT repo_name, count() AS total_stars, STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts, TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds, (STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514) / ((TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at))) + 1e-9) AS steadiness_ratio FROM github_llm_bench.github_events A", + "length": 2 + }, + "name": "pipe_15.pipe", + "question": { + "name": "pipe_15.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most steady star growth rate over time\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n max(stars) AS daily_stars,\n sum(stars) AS total_stars,\n total_stars / daily_stars AS rate\n FROM\n (\n SELECT\n repo_name,\n toDate(created_at) AS day,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY\n repo_name,\n day\n )\n GROUP BY repo_name\n ORDER BY rate DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the most steady star growth rate over time" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.974, + "totalDuration": 81.776, + "tokens": { + "promptTokens": 4587, + "completionTokens": 9398, + "totalTokens": 13985 + } + }, + "error": null + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most steady star growth rate over time\\\"\\n\\nYou generated this SQL query:\\n```sql\\n\\nSELECT\\n repo_name,\\n count() AS total_stars,\\n STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts,\\n TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds,\\n STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514 / (TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) + 1e-9) AS steadiness_ratio\\nFROM github_events\\nWHERE event_type = 'WatchEvent'\\n AND created_at >= now() - INTERVAL 1 YEAR\\nGROUP BY repo_name\\nHAVING total_stars >= 100\\n AND TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) > 0\\nORDER BY steadiness_ratio DESC, total_stars DESC\\nLIMIT 10\\n\\n```\\n\\nBut it resulted in this error:\\n```\\n{\\\"error\\\": \\\"[Error] A value of illegal type was provided as 1st argument 'time' to function 'parseDateTime'. Expected: String, got: DateTime: In scope SELECT repo_name, count() AS total_stars, STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts, TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds, (STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514) / ((TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at))) + 1e-9) AS steadiness_ratio FROM github_llm_bench.github_events A\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b1a369ac14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:08:26 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_15.pipe", + "question": { + "name": "pipe_15.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most steady star growth rate over time\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n max(stars) AS daily_stars,\n sum(stars) AS total_stars,\n total_stars / daily_stars AS rate\n FROM\n (\n SELECT\n repo_name,\n toDate(created_at) AS day,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY\n repo_name,\n day\n )\n GROUP BY repo_name\n ORDER BY rate DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 Repositories with the most steady star growth rate over time\"\n\nYou generated this SQL query:\n```sql\n\nSELECT\n repo_name,\n count() AS total_stars,\n STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts,\n TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds,\n STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514 / (TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) + 1e-9) AS steadiness_ratio\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND created_at >= now() - INTERVAL 1 YEAR\nGROUP BY repo_name\nHAVING total_stars >= 100\n AND TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) > 0\nORDER BY steadiness_ratio DESC, total_stars DESC\nLIMIT 10\n\n```\n\nBut it resulted in this error:\n```\n{\"error\": \"[Error] A value of illegal type was provided as 1st argument 'time' to function 'parseDateTime'. Expected: String, got: DateTime: In scope SELECT repo_name, count() AS total_stars, STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts, TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds, (STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514) / ((TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at))) + 1e-9) AS steadiness_ratio FROM github_llm_bench.github_events A\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": "\nSELECT\n repo_name,\n count() AS total_stars,\n STDDEV_POP(CAST(created_at AS UInt32)) AS std_ts,\n CAST(max(created_at) AS UInt32) - CAST(min(created_at) AS UInt32) AS span_seconds,\n STDDEV_POP(CAST(created_at AS UInt32)) * 3.46410161514 / (CAST(max(created_at) AS UInt32) - CAST(min(created_at) AS UInt32) + 1e-9) AS steadiness_ratio\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND created_at >= now() - INTERVAL 1 YEAR\nGROUP BY repo_name\nHAVING total_stars >= 100\n AND span_seconds > 0\nORDER BY steadiness_ratio DESC, total_stars DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "total_stars", + "type": "UInt64" + }, + { + "name": "std_ts", + "type": "Float64" + }, + { + "name": "span_seconds", + "type": "Int64" + }, + { + "name": "steadiness_ratio", + "type": "Float64" + } + ], + "statistics": { + "elapsed": 0.005841623, + "rows_read": 0, + "bytes_read": 0 + }, + "executionTime": 0.107, + "requestId": "01KA4B9M16X8H8CRATZHJ7CCYK", + "length": 2 + }, + "name": "pipe_15.pipe", + "question": { + "name": "pipe_15.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most steady star growth rate over time\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n max(stars) AS daily_stars,\n sum(stars) AS total_stars,\n total_stars / daily_stars AS rate\n FROM\n (\n SELECT\n repo_name,\n toDate(created_at) AS day,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY\n repo_name,\n day\n )\n GROUP BY repo_name\n ORDER BY rate DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the most steady star growth rate over time\"\n\nYou generated this SQL query:\n```sql\n\nSELECT\n repo_name,\n count() AS total_stars,\n STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts,\n TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds,\n STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514 / (TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) + 1e-9) AS steadiness_ratio\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND created_at >= now() - INTERVAL 1 YEAR\nGROUP BY repo_name\nHAVING total_stars >= 100\n AND TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) > 0\nORDER BY steadiness_ratio DESC, total_stars DESC\nLIMIT 10\n\n```\n\nBut it resulted in this error:\n```\n{\"error\": \"[Error] A value of illegal type was provided as 1st argument 'time' to function 'parseDateTime'. Expected: String, got: DateTime: In scope SELECT repo_name, count() AS total_stars, STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts, TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds, (STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514) / ((TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at))) + 1e-9) AS steadiness_ratio FROM github_llm_bench.github_events A\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most steady star growth rate over time\\\"\\n\\nYou generated this SQL query:\\n```sql\\n\\nSELECT\\n repo_name,\\n count() AS total_stars,\\n STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts,\\n TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds,\\n STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514 / (TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) + 1e-9) AS steadiness_ratio\\nFROM github_events\\nWHERE event_type = 'WatchEvent'\\n AND created_at >= now() - INTERVAL 1 YEAR\\nGROUP BY repo_name\\nHAVING total_stars >= 100\\n AND TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) > 0\\nORDER BY steadiness_ratio DESC, total_stars DESC\\nLIMIT 10\\n\\n```\\n\\nBut it resulted in this error:\\n```\\n{\\\"error\\\": \\\"[Error] A value of illegal type was provided as 1st argument 'time' to function 'parseDateTime'. Expected: String, got: DateTime: In scope SELECT repo_name, count() AS total_stars, STDDEV_POP(TO_UNIXTIME(created_at)) AS std_ts, TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at)) AS span_seconds, (STDDEV_POP(TO_UNIXTIME(created_at)) * 3.46410161514) / ((TO_UNIXTIME(max(created_at)) - TO_UNIXTIME(min(created_at))) + 1e-9) AS steadiness_ratio FROM github_llm_bench.github_events A\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b1a369ac14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:08:26 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.658, + "totalDuration": 33.778, + "tokens": { + "promptTokens": 10349, + "completionTokens": 4459, + "totalTokens": 14808 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"What is the best day of the week to catch a star?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What is the best day of the week to catch a star?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872ec64fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"What is the best day of the week to catch a star?\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"What is the best day of the week to catch a star?\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2872ec64fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2878e5614ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287da26874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_16.pipe", + "question": { + "name": "pipe_16.pipe", + "content": "DESCRIPTION >\n What is the best day of the week to catch a star?\n\nNODE endpoint\nSQL >\n SELECT toDayOfWeek(created_at) AS day, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY day ORDER BY day\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"What is the best day of the week to catch a star?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"What is the best day of the week to catch a star?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872ec64fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"What is the best day of the week to catch a star?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What is the best day of the week to catch a star?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872ec64fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2878e5614ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"What is the best day of the week to catch a star?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872ec64fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_16.pipe", + "question": { + "name": "pipe_16.pipe", + "content": "DESCRIPTION >\n What is the best day of the week to catch a star?\n\nNODE endpoint\nSQL >\n SELECT toDayOfWeek(created_at) AS day, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY day ORDER BY day\n\nTYPE endpoint", + "question": "What is the best day of the week to catch a star?" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"What is the best day of the week to catch a star?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What is the best day of the week to catch a star?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872ec64fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2878e5614ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_16.pipe", + "question": { + "name": "pipe_16.pipe", + "content": "DESCRIPTION >\n What is the best day of the week to catch a star?\n\nNODE endpoint\nSQL >\n SELECT toDayOfWeek(created_at) AS day, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY day ORDER BY day\n\nTYPE endpoint", + "question": "I previously asked: \"What is the best day of the week to catch a star?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"What is the best day of the week to catch a star?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872ec64fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"What is the best day of the week to catch a star?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What is the best day of the week to catch a star?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872ec64fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"What is the best day of the week to catch a star?\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"What is the best day of the week to catch a star?\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2872ec64fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2878e5614ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287da26874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_16.pipe", + "question": { + "name": "pipe_16.pipe", + "content": "DESCRIPTION >\n What is the best day of the week to catch a star?\n\nNODE endpoint\nSQL >\n SELECT toDayOfWeek(created_at) AS day, count() AS stars FROM github_events WHERE event_type = 'WatchEvent' GROUP BY day ORDER BY day\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"What is the best day of the week to catch a star?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"What is the best day of the week to catch a star?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872ec64fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"What is the best day of the week to catch a star?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What is the best day of the week to catch a star?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872ec64fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2878e5614ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT uniqExact(actor_login) AS total_users FROM github_events LIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "total_users": 9426561 + } + ], + "meta": [ + { + "name": "total_users", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.899090978, + "rows_read": 200000000, + "bytes_read": 791683021 + }, + "executionTime": 1.003, + "requestId": "01KA4B9X63ZFEYTRJJWVJ411T1", + "length": 25 + }, + "name": "pipe_17.pipe", + "question": { + "name": "pipe_17.pipe", + "content": "DESCRIPTION >\n The total number of users on GitHub\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events\n\nTYPE endpoint", + "question": "The total number of users on GitHub" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.546, + "totalDuration": 6.764, + "tokens": { + "promptTokens": 4581, + "completionTokens": 790, + "totalTokens": 5371 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT uniqExact(actor_login) AS total_users FROM github_events LIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "total_users": 9426561 + } + ], + "meta": [ + { + "name": "total_users", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.899090978, + "rows_read": 200000000, + "bytes_read": 791683021 + }, + "executionTime": 1.003, + "requestId": "01KA4B9X63ZFEYTRJJWVJ411T1", + "length": 25 + }, + "name": "pipe_17.pipe", + "question": { + "name": "pipe_17.pipe", + "content": "DESCRIPTION >\n The total number of users on GitHub\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events\n\nTYPE endpoint", + "question": "The total number of users on GitHub" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.546, + "totalDuration": 6.764, + "tokens": { + "promptTokens": 4581, + "completionTokens": 790, + "totalTokens": 5371 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Total number of users that gave at least one star\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users that gave at least one star\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872985874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Total number of users that gave at least one star\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Total number of users that gave at least one star\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2872985874f-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b287c8a54fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287f9a3eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_18.pipe", + "question": { + "name": "pipe_18.pipe", + "content": "DESCRIPTION >\n Total number of users that gave at least one star\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'WatchEvent'\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Total number of users that gave at least one star\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Total number of users that gave at least one star\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872985874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Total number of users that gave at least one star\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users that gave at least one star\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872985874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287c8a54fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Total number of users that gave at least one star\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872985874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_18.pipe", + "question": { + "name": "pipe_18.pipe", + "content": "DESCRIPTION >\n Total number of users that gave at least one star\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'WatchEvent'\n\nTYPE endpoint", + "question": "Total number of users that gave at least one star" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Total number of users that gave at least one star\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users that gave at least one star\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872985874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287c8a54fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_18.pipe", + "question": { + "name": "pipe_18.pipe", + "content": "DESCRIPTION >\n Total number of users that gave at least one star\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'WatchEvent'\n\nTYPE endpoint", + "question": "I previously asked: \"Total number of users that gave at least one star\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Total number of users that gave at least one star\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872985874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Total number of users that gave at least one star\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users that gave at least one star\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872985874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Total number of users that gave at least one star\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Total number of users that gave at least one star\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2872985874f-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b287c8a54fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287f9a3eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_18.pipe", + "question": { + "name": "pipe_18.pipe", + "content": "DESCRIPTION >\n Total number of users that gave at least one star\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'WatchEvent'\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Total number of users that gave at least one star\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Total number of users that gave at least one star\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872985874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Total number of users that gave at least one star\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users that gave at least one star\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872985874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287c8a54fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT countDistinct(actor_login) FROM github_events WHERE event_type = 'PushEvent' LIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "countDistinct(actor_login)": 1721766 + } + ], + "meta": [ + { + "name": "countDistinct(actor_login)", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.24673893, + "rows_read": 75572830, + "bytes_read": 238309784 + }, + "executionTime": 0.54, + "requestId": "01KA4B9VGWYTCK5EF7QTFFC2Q0", + "length": 40 + }, + "name": "pipe_19.pipe", + "question": { + "name": "pipe_19.pipe", + "content": "DESCRIPTION >\n Total number of users with at least one push\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'PushEvent'\n\nTYPE endpoint", + "question": "Total number of users with at least one push" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.424, + "totalDuration": 4.872, + "tokens": { + "promptTokens": 4582, + "completionTokens": 592, + "totalTokens": 5174 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT countDistinct(actor_login) FROM github_events WHERE event_type = 'PushEvent' LIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "countDistinct(actor_login)": 1721766 + } + ], + "meta": [ + { + "name": "countDistinct(actor_login)", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.24673893, + "rows_read": 75572830, + "bytes_read": 238309784 + }, + "executionTime": 0.54, + "requestId": "01KA4B9VGWYTCK5EF7QTFFC2Q0", + "length": 40 + }, + "name": "pipe_19.pipe", + "question": { + "name": "pipe_19.pipe", + "content": "DESCRIPTION >\n Total number of users with at least one push\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'PushEvent'\n\nTYPE endpoint", + "question": "Total number of users with at least one push" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.424, + "totalDuration": 4.872, + "tokens": { + "promptTokens": 4582, + "completionTokens": 592, + "totalTokens": 5174 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Total number of users with at least one created PR\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users with at least one created PR\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872d2714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Total number of users with at least one created PR\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Total number of users with at least one created PR\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2872d2714ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2879836eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287efec14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_20.pipe", + "question": { + "name": "pipe_20.pipe", + "content": "DESCRIPTION >\n Total number of users with at least one created PR\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened'\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Total number of users with at least one created PR\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Total number of users with at least one created PR\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872d2714ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Total number of users with at least one created PR\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users with at least one created PR\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872d2714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2879836eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Total number of users with at least one created PR\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872d2714ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_20.pipe", + "question": { + "name": "pipe_20.pipe", + "content": "DESCRIPTION >\n Total number of users with at least one created PR\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened'\n\nTYPE endpoint", + "question": "Total number of users with at least one created PR" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Total number of users with at least one created PR\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users with at least one created PR\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872d2714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2879836eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_20.pipe", + "question": { + "name": "pipe_20.pipe", + "content": "DESCRIPTION >\n Total number of users with at least one created PR\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened'\n\nTYPE endpoint", + "question": "I previously asked: \"Total number of users with at least one created PR\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Total number of users with at least one created PR\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872d2714ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Total number of users with at least one created PR\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users with at least one created PR\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872d2714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Total number of users with at least one created PR\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Total number of users with at least one created PR\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2872d2714ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2879836eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b287efec14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_20.pipe", + "question": { + "name": "pipe_20.pipe", + "content": "DESCRIPTION >\n Total number of users with at least one created PR\n\nNODE endpoint\nSQL >\n SELECT uniq(actor_login) FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened'\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Total number of users with at least one created PR\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Total number of users with at least one created PR\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2872d2714ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Total number of users with at least one created PR\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Total number of users with at least one created PR\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2872d2714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:02 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2879836eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:02 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c759534fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2c759534fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c7b8039a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c8194214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_21.pipe", + "question": { + "name": "pipe_21.pipe", + "content": "DESCRIPTION >\n What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count()\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened')\n ))\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c759534fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c759534fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7b8039a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c759534fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_21.pipe", + "question": { + "name": "pipe_21.pipe", + "content": "DESCRIPTION >\n What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count()\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened')\n ))\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c759534fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7b8039a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_21.pipe", + "question": { + "name": "pipe_21.pipe", + "content": "DESCRIPTION >\n What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count()\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened')\n ))\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c759534fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c759534fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2c759534fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c7b8039a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c8194214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_21.pipe", + "question": { + "name": "pipe_21.pipe", + "content": "DESCRIPTION >\n What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count()\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened')\n ))\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c759534fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"What if we count top 10 starred repositories but only from those users who made at least one PR in at least one repo?\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c759534fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7b8039a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "SELECT repo_name, sum(pr_count) AS total_prs_by_prolific_authors FROM (SELECT repo_name, actor_login, count() AS pr_count FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name, actor_login HAVING pr_count >= 10) GROUP BY repo_name ORDER BY total_prs_by_prolific_authors DESC LIMIT 10", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "sauron-demo/sauron", + "total_prs_by_prolific_authors": 109608 + }, + { + "repo_name": "google-test/signcla-probe-repo", + "total_prs_by_prolific_authors": 43435 + }, + { + "repo_name": "sauron-demo/sauron-demo", + "total_prs_by_prolific_authors": 31274 + }, + { + "repo_name": "everypolitician/everypolitician-data", + "total_prs_by_prolific_authors": 13276 + }, + { + "repo_name": "ros/rosdistro", + "total_prs_by_prolific_authors": 12037 + }, + { + "repo_name": "rust-lang/rust", + "total_prs_by_prolific_authors": 11109 + }, + { + "repo_name": "kubernetes/kubernetes", + "total_prs_by_prolific_authors": 9441 + }, + { + "repo_name": "saltstack/salt", + "total_prs_by_prolific_authors": 8662 + }, + { + "repo_name": "nodejs/node", + "total_prs_by_prolific_authors": 7192 + }, + { + "repo_name": "symfony/symfony", + "total_prs_by_prolific_authors": 7034 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "total_prs_by_prolific_authors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.227229019, + "rows_read": 18340176, + "bytes_read": 146530764 + }, + "executionTime": 0.331, + "requestId": "01KA4BAVE7S04MT6D13ZT1V2RH", + "length": 743 + }, + "name": "pipe_22.pipe", + "question": { + "name": "pipe_22.pipe", + "content": "DESCRIPTION >\n top 10 repos with authors who have made at least 10 PRs?\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count()\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened')\n GROUP BY actor_login\n HAVING count() >= 10\n ))\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 repos with authors who have made at least 10 PRs?" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.32, + "totalDuration": 27.472, + "tokens": { + "promptTokens": 4589, + "completionTokens": 3980, + "totalTokens": 8569 + } + }, + "error": null, + "attempts": [ + { + "sql": "SELECT repo_name, sum(pr_count) AS total_prs_by_prolific_authors FROM (SELECT repo_name, actor_login, count() AS pr_count FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name, actor_login HAVING pr_count >= 10) GROUP BY repo_name ORDER BY total_prs_by_prolific_authors DESC LIMIT 10", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "sauron-demo/sauron", + "total_prs_by_prolific_authors": 109608 + }, + { + "repo_name": "google-test/signcla-probe-repo", + "total_prs_by_prolific_authors": 43435 + }, + { + "repo_name": "sauron-demo/sauron-demo", + "total_prs_by_prolific_authors": 31274 + }, + { + "repo_name": "everypolitician/everypolitician-data", + "total_prs_by_prolific_authors": 13276 + }, + { + "repo_name": "ros/rosdistro", + "total_prs_by_prolific_authors": 12037 + }, + { + "repo_name": "rust-lang/rust", + "total_prs_by_prolific_authors": 11109 + }, + { + "repo_name": "kubernetes/kubernetes", + "total_prs_by_prolific_authors": 9441 + }, + { + "repo_name": "saltstack/salt", + "total_prs_by_prolific_authors": 8662 + }, + { + "repo_name": "nodejs/node", + "total_prs_by_prolific_authors": 7192 + }, + { + "repo_name": "symfony/symfony", + "total_prs_by_prolific_authors": 7034 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "total_prs_by_prolific_authors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.227229019, + "rows_read": 18340176, + "bytes_read": 146530764 + }, + "executionTime": 0.331, + "requestId": "01KA4BAVE7S04MT6D13ZT1V2RH", + "length": 743 + }, + "name": "pipe_22.pipe", + "question": { + "name": "pipe_22.pipe", + "content": "DESCRIPTION >\n top 10 repos with authors who have made at least 10 PRs?\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count()\n FROM github_events\n WHERE (event_type = 'WatchEvent') AND (actor_login IN\n (\n SELECT actor_login\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened')\n GROUP BY actor_login\n HAVING count() >= 10\n ))\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 repos with authors who have made at least 10 PRs?" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.32, + "totalDuration": 27.472, + "tokens": { + "promptTokens": 4589, + "completionTokens": 3980, + "totalTokens": 8569 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the maximum amount of pull requests\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of pull requests\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c75de5eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the maximum amount of pull requests\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the maximum amount of pull requests\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2c75de5eb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c7bed2874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7ef4aeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_23.pipe", + "question": { + "name": "pipe_23.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of pull requests\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the maximum amount of pull requests\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the maximum amount of pull requests\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c75de5eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the maximum amount of pull requests\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of pull requests\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c75de5eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7bed2874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the maximum amount of pull requests\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c75de5eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_23.pipe", + "question": { + "name": "pipe_23.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of pull requests\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the maximum amount of pull requests" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the maximum amount of pull requests\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of pull requests\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c75de5eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7bed2874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_23.pipe", + "question": { + "name": "pipe_23.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of pull requests\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 Repositories with the maximum amount of pull requests\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the maximum amount of pull requests\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c75de5eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the maximum amount of pull requests\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of pull requests\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c75de5eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the maximum amount of pull requests\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the maximum amount of pull requests\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2c75de5eb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c7bed2874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7ef4aeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_23.pipe", + "question": { + "name": "pipe_23.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of pull requests\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the maximum amount of pull requests\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the maximum amount of pull requests\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c75de5eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the maximum amount of pull requests\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of pull requests\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c75de5eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7bed2874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n repo_name,\n count(distinct actor_login) AS pr_contributors\nFROM github_events\nWHERE event_type = 'PullRequestEvent' AND action = 'opened'\nGROUP BY repo_name\nORDER BY pr_contributors DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "jlord/patchwork", + "pr_contributors": 5802 + }, + { + "repo_name": "githubschool/open-enrollment-classes-introduction-to-github", + "pr_contributors": 3586 + }, + { + "repo_name": "learn-co-students/javascript-intro-to-functions-lab-bootcamp-prep-000", + "pr_contributors": 3027 + }, + { + "repo_name": "learn-co-students/js-functions-lab-bootcamp-prep-000", + "pr_contributors": 2899 + }, + { + "repo_name": "learn-co-students/js-from-dom-to-node-bootcamp-prep-000", + "pr_contributors": 2860 + }, + { + "repo_name": "learn-co-students/javascript-arithmetic-lab-bootcamp-prep-000", + "pr_contributors": 2681 + }, + { + "repo_name": "udacity/create-your-own-adventure", + "pr_contributors": 2622 + }, + { + "repo_name": "learn-co-students/js-node-practice-lab-bootcamp-prep-000", + "pr_contributors": 2594 + }, + { + "repo_name": "freeCodeCamp/guides", + "pr_contributors": 2587 + }, + { + "repo_name": "learn-co-students/js-if-else-files-lab-bootcamp-prep-000", + "pr_contributors": 2581 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "pr_contributors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.174558027, + "rows_read": 18340176, + "bytes_read": 146530764 + }, + "executionTime": 0.279, + "requestId": "01KA4BA82V1QR2MX6Z48YVMMYJ", + "length": 876 + }, + "name": "pipe_24.pipe", + "question": { + "name": "pipe_24.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of pull request contributors\n\nNODE endpoint\nSQL >\n SELECT repo_name, uniqExact(actor_login) AS u FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name ORDER BY u DESC LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the maximum amount of pull request contributors" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.395, + "totalDuration": 7.652, + "tokens": { + "promptTokens": 4586, + "completionTokens": 949, + "totalTokens": 5535 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n repo_name,\n count(distinct actor_login) AS pr_contributors\nFROM github_events\nWHERE event_type = 'PullRequestEvent' AND action = 'opened'\nGROUP BY repo_name\nORDER BY pr_contributors DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "jlord/patchwork", + "pr_contributors": 5802 + }, + { + "repo_name": "githubschool/open-enrollment-classes-introduction-to-github", + "pr_contributors": 3586 + }, + { + "repo_name": "learn-co-students/javascript-intro-to-functions-lab-bootcamp-prep-000", + "pr_contributors": 3027 + }, + { + "repo_name": "learn-co-students/js-functions-lab-bootcamp-prep-000", + "pr_contributors": 2899 + }, + { + "repo_name": "learn-co-students/js-from-dom-to-node-bootcamp-prep-000", + "pr_contributors": 2860 + }, + { + "repo_name": "learn-co-students/javascript-arithmetic-lab-bootcamp-prep-000", + "pr_contributors": 2681 + }, + { + "repo_name": "udacity/create-your-own-adventure", + "pr_contributors": 2622 + }, + { + "repo_name": "learn-co-students/js-node-practice-lab-bootcamp-prep-000", + "pr_contributors": 2594 + }, + { + "repo_name": "freeCodeCamp/guides", + "pr_contributors": 2587 + }, + { + "repo_name": "learn-co-students/js-if-else-files-lab-bootcamp-prep-000", + "pr_contributors": 2581 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "pr_contributors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.174558027, + "rows_read": 18340176, + "bytes_read": 146530764 + }, + "executionTime": 0.279, + "requestId": "01KA4BA82V1QR2MX6Z48YVMMYJ", + "length": 876 + }, + "name": "pipe_24.pipe", + "question": { + "name": "pipe_24.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of pull request contributors\n\nNODE endpoint\nSQL >\n SELECT repo_name, uniqExact(actor_login) AS u FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name ORDER BY u DESC LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the maximum amount of pull request contributors" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.395, + "totalDuration": 7.652, + "tokens": { + "promptTokens": 4586, + "completionTokens": 949, + "totalTokens": 5535 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the maximum amount of issues\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of issues\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c76fdc14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the maximum amount of issues\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the maximum amount of issues\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2c76fdc14ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c79e75eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7daf84fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_25.pipe", + "question": { + "name": "pipe_25.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of issues\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS c FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened' GROUP BY repo_name ORDER BY c DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the maximum amount of issues\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the maximum amount of issues\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c76fdc14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the maximum amount of issues\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of issues\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c76fdc14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c79e75eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the maximum amount of issues\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c76fdc14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_25.pipe", + "question": { + "name": "pipe_25.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of issues\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS c FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened' GROUP BY repo_name ORDER BY c DESC LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the maximum amount of issues" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the maximum amount of issues\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of issues\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c76fdc14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c79e75eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_25.pipe", + "question": { + "name": "pipe_25.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of issues\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS c FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened' GROUP BY repo_name ORDER BY c DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 Repositories with the maximum amount of issues\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the maximum amount of issues\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c76fdc14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the maximum amount of issues\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of issues\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c76fdc14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the maximum amount of issues\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the maximum amount of issues\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b2c76fdc14ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c79e75eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c7daf84fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_25.pipe", + "question": { + "name": "pipe_25.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the maximum amount of issues\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS c FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened' GROUP BY repo_name ORDER BY c DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the maximum amount of issues\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the maximum amount of issues\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c76fdc14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the maximum amount of issues\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the maximum amount of issues\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b2c76fdc14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b2c79e75eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the most people who have push access\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384bf924fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the most people who have push access\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the most people who have push access\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b384bf924fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b38589c36188-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385fb174fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_26.pipe", + "question": { + "name": "pipe_26.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access\n\nNODE endpoint\nSQL >\n SELECT repo_name, uniqIf(actor_login, event_type = 'PushEvent') AS u FROM github_events WHERE event_type IN ('PushEvent', 'WatchEvent') GROUP BY repo_name ORDER BY u DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the most people who have push access\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the most people who have push access\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384bf924fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most people who have push access\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384bf924fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b38589c36188-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the most people who have push access\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384bf924fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_26.pipe", + "question": { + "name": "pipe_26.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access\n\nNODE endpoint\nSQL >\n SELECT repo_name, uniqIf(actor_login, event_type = 'PushEvent') AS u FROM github_events WHERE event_type IN ('PushEvent', 'WatchEvent') GROUP BY repo_name ORDER BY u DESC LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the most people who have push access" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most people who have push access\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384bf924fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b38589c36188-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_26.pipe", + "question": { + "name": "pipe_26.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access\n\nNODE endpoint\nSQL >\n SELECT repo_name, uniqIf(actor_login, event_type = 'PushEvent') AS u FROM github_events WHERE event_type IN ('PushEvent', 'WatchEvent') GROUP BY repo_name ORDER BY u DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 Repositories with the most people who have push access\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the most people who have push access\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384bf924fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the most people who have push access\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384bf924fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the most people who have push access\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the most people who have push access\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b384bf924fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b38589c36188-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385fb174fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_26.pipe", + "question": { + "name": "pipe_26.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access\n\nNODE endpoint\nSQL >\n SELECT repo_name, uniqIf(actor_login, event_type = 'PushEvent') AS u FROM github_events WHERE event_type IN ('PushEvent', 'WatchEvent') GROUP BY repo_name ORDER BY u DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the most people who have push access\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the most people who have push access\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384bf924fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most people who have push access\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384bf924fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b38589c36188-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n repo_name,\n countDistinct(actor_login) AS pushers_count\nFROM github_events\nWHERE event_type = 'PushEvent'\n AND ref = 'refs/heads/main'\nGROUP BY repo_name\nORDER BY pushers_count DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "github/codeql", + "pushers_count": 29 + }, + { + "repo_name": "githubschool/chilly-wind", + "pushers_count": 21 + }, + { + "repo_name": "google/web-stories-wp", + "pushers_count": 21 + }, + { + "repo_name": "github/docs", + "pushers_count": 21 + }, + { + "repo_name": "google/iree", + "pushers_count": 18 + }, + { + "repo_name": "githubschool/floss-workshop", + "pushers_count": 18 + }, + { + "repo_name": "githubschool/intel-inside", + "pushers_count": 16 + }, + { + "repo_name": "gallenc/solent6Public", + "pushers_count": 15 + }, + { + "repo_name": "githubschool/biz-dev", + "pushers_count": 13 + }, + { + "repo_name": "github/codeql-action", + "pushers_count": 13 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "pushers_count", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.273844398, + "rows_read": 75572830, + "bytes_read": 2239911125 + }, + "executionTime": 0.377, + "requestId": "01KA4BB2XTQXRS7VNMCENAPZ5T", + "length": 554 + }, + "name": "pipe_27.pipe", + "question": { + "name": "pipe_27.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access to the main branch\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n uniqIf(actor_login, (event_type = 'PushEvent') AND match(ref, '/(main|master)$')) AS u\n FROM github_events\n WHERE (event_type IN ('PushEvent', 'WatchEvent'))\n GROUP BY repo_name\n ORDER BY u DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the most people who have push access to the main branch" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.332, + "totalDuration": 4.832, + "tokens": { + "promptTokens": 4590, + "completionTokens": 670, + "totalTokens": 5260 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n repo_name,\n countDistinct(actor_login) AS pushers_count\nFROM github_events\nWHERE event_type = 'PushEvent'\n AND ref = 'refs/heads/main'\nGROUP BY repo_name\nORDER BY pushers_count DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "github/codeql", + "pushers_count": 29 + }, + { + "repo_name": "githubschool/chilly-wind", + "pushers_count": 21 + }, + { + "repo_name": "google/web-stories-wp", + "pushers_count": 21 + }, + { + "repo_name": "github/docs", + "pushers_count": 21 + }, + { + "repo_name": "google/iree", + "pushers_count": 18 + }, + { + "repo_name": "githubschool/floss-workshop", + "pushers_count": 18 + }, + { + "repo_name": "githubschool/intel-inside", + "pushers_count": 16 + }, + { + "repo_name": "gallenc/solent6Public", + "pushers_count": 15 + }, + { + "repo_name": "githubschool/biz-dev", + "pushers_count": 13 + }, + { + "repo_name": "github/codeql-action", + "pushers_count": 13 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "pushers_count", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.273844398, + "rows_read": 75572830, + "bytes_read": 2239911125 + }, + "executionTime": 0.377, + "requestId": "01KA4BB2XTQXRS7VNMCENAPZ5T", + "length": 554 + }, + "name": "pipe_27.pipe", + "question": { + "name": "pipe_27.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access to the main branch\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n uniqIf(actor_login, (event_type = 'PushEvent') AND match(ref, '/(main|master)$')) AS u\n FROM github_events\n WHERE (event_type IN ('PushEvent', 'WatchEvent'))\n GROUP BY repo_name\n ORDER BY u DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the most people who have push access to the main branch" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.332, + "totalDuration": 4.832, + "tokens": { + "promptTokens": 4590, + "completionTokens": 670, + "totalTokens": 5260 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384cb4814ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b384cb4814ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3857e80f50d-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385cdd514ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_28.pipe", + "question": { + "name": "pipe_28.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n uniqIf(actor_login, (event_type = 'PushEvent') AND match(ref, '/(main|master)$')) AS u,\n sum(event_type = 'WatchEvent') AS stars\n FROM github_events\n WHERE (event_type IN ('PushEvent', 'WatchEvent')) AND (repo_name != '/')\n GROUP BY repo_name\n HAVING stars >= 100\n ORDER BY u DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384cb4814ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384cb4814ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3857e80f50d-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384cb4814ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_28.pipe", + "question": { + "name": "pipe_28.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n uniqIf(actor_login, (event_type = 'PushEvent') AND match(ref, '/(main|master)$')) AS u,\n sum(event_type = 'WatchEvent') AS stars\n FROM github_events\n WHERE (event_type IN ('PushEvent', 'WatchEvent')) AND (repo_name != '/')\n GROUP BY repo_name\n HAVING stars >= 100\n ORDER BY u DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384cb4814ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3857e80f50d-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_28.pipe", + "question": { + "name": "pipe_28.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n uniqIf(actor_login, (event_type = 'PushEvent') AND match(ref, '/(main|master)$')) AS u,\n sum(event_type = 'WatchEvent') AS stars\n FROM github_events\n WHERE (event_type IN ('PushEvent', 'WatchEvent')) AND (repo_name != '/')\n GROUP BY repo_name\n HAVING stars >= 100\n ORDER BY u DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384cb4814ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384cb4814ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b384cb4814ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3857e80f50d-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385cdd514ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_28.pipe", + "question": { + "name": "pipe_28.pipe", + "content": "DESCRIPTION >\n top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n uniqIf(actor_login, (event_type = 'PushEvent') AND match(ref, '/(main|master)$')) AS u,\n sum(event_type = 'WatchEvent') AS stars\n FROM github_events\n WHERE (event_type IN ('PushEvent', 'WatchEvent')) AND (repo_name != '/')\n GROUP BY repo_name\n HAVING stars >= 100\n ORDER BY u DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384cb4814ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Repositories with the most people who have push access to the main branch With a cutoff for the number of stars at more than 99\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384cb4814ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3857e80f50d-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 repositories by maximum number of member invitations\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by maximum number of member invitations\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384b9d7874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 repositories by maximum number of member invitations\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 repositories by maximum number of member invitations\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b384b9d7874f-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b385592f4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3858a8f874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_29.pipe", + "question": { + "name": "pipe_29.pipe", + "content": "DESCRIPTION >\n Top 10 repositories by maximum number of member invitations\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS invitations FROM github_events WHERE event_type = 'MemberEvent' AND action = 'added' GROUP BY repo_name ORDER BY invitations DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 repositories by maximum number of member invitations\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 repositories by maximum number of member invitations\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384b9d7874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 repositories by maximum number of member invitations\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by maximum number of member invitations\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384b9d7874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385592f4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 repositories by maximum number of member invitations\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384b9d7874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_29.pipe", + "question": { + "name": "pipe_29.pipe", + "content": "DESCRIPTION >\n Top 10 repositories by maximum number of member invitations\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS invitations FROM github_events WHERE event_type = 'MemberEvent' AND action = 'added' GROUP BY repo_name ORDER BY invitations DESC LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 repositories by maximum number of member invitations" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 repositories by maximum number of member invitations\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by maximum number of member invitations\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384b9d7874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385592f4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_29.pipe", + "question": { + "name": "pipe_29.pipe", + "content": "DESCRIPTION >\n Top 10 repositories by maximum number of member invitations\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS invitations FROM github_events WHERE event_type = 'MemberEvent' AND action = 'added' GROUP BY repo_name ORDER BY invitations DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 repositories by maximum number of member invitations\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 repositories by maximum number of member invitations\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384b9d7874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 repositories by maximum number of member invitations\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by maximum number of member invitations\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384b9d7874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 repositories by maximum number of member invitations\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 repositories by maximum number of member invitations\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b384b9d7874f-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b385592f4fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3858a8f874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_29.pipe", + "question": { + "name": "pipe_29.pipe", + "content": "DESCRIPTION >\n Top 10 repositories by maximum number of member invitations\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS invitations FROM github_events WHERE event_type = 'MemberEvent' AND action = 'added' GROUP BY repo_name ORDER BY invitations DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 repositories by maximum number of member invitations\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 repositories by maximum number of member invitations\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384b9d7874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 repositories by maximum number of member invitations\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 repositories by maximum number of member invitations\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384b9d7874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385592f4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Most forked repositories\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Most forked repositories\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384caef9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Most forked repositories\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Most forked repositories\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b384caef9a2e-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3856d0b14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385ba6b4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_30.pipe", + "question": { + "name": "pipe_30.pipe", + "content": "DESCRIPTION >\n top 10 Most forked repositories\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS forks FROM github_events WHERE event_type = 'ForkEvent' GROUP BY repo_name ORDER BY forks DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Most forked repositories\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Most forked repositories\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384caef9a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Most forked repositories\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Most forked repositories\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384caef9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3856d0b14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Most forked repositories\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384caef9a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_30.pipe", + "question": { + "name": "pipe_30.pipe", + "content": "DESCRIPTION >\n top 10 Most forked repositories\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS forks FROM github_events WHERE event_type = 'ForkEvent' GROUP BY repo_name ORDER BY forks DESC LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Most forked repositories" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Most forked repositories\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Most forked repositories\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384caef9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3856d0b14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_30.pipe", + "question": { + "name": "pipe_30.pipe", + "content": "DESCRIPTION >\n top 10 Most forked repositories\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS forks FROM github_events WHERE event_type = 'ForkEvent' GROUP BY repo_name ORDER BY forks DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 Most forked repositories\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Most forked repositories\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384caef9a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"top 10 Most forked repositories\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Most forked repositories\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384caef9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"top 10 Most forked repositories\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"top 10 Most forked repositories\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b384caef9a2e-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3856d0b14ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b385ba6b4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_30.pipe", + "question": { + "name": "pipe_30.pipe", + "content": "DESCRIPTION >\n top 10 Most forked repositories\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() AS forks FROM github_events WHERE event_type = 'ForkEvent' GROUP BY repo_name ORDER BY forks DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"top 10 Most forked repositories\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 Most forked repositories\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b384caef9a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"top 10 Most forked repositories\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"top 10 Most forked repositories\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b384caef9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:43 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3856d0b14ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:43 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n repo_name,\n sum(event_type = 'WatchEvent') AS stars,\n sum(event_type = 'ForkEvent') AS forks,\n sum(event_type = 'WatchEvent') / sum(event_type = 'ForkEvent') AS star_fork_ratio\nFROM github_events\nWHERE event_type IN ('WatchEvent', 'ForkEvent')\nGROUP BY repo_name\nHAVING sum(event_type = 'ForkEvent') > 0\nORDER BY star_fork_ratio DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "CHEF-KOCH/VSCode-Settings", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "Dataweekends/pong_reinforcement_learning", + "stars": 0, + "forks": 2, + "star_fork_ratio": 0 + }, + { + "repo_name": "PeterCxy/android_system_core", + "stars": 0, + "forks": 2, + "star_fork_ratio": 0 + }, + { + "repo_name": "Gforcex/OpenGraphic", + "stars": 0, + "forks": 34, + "star_fork_ratio": 0 + }, + { + "repo_name": "ZarinNegah/mtpbulksecret", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "GSA/digital.gov-design", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "aki270/aki52", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "c6burns/udp_in_ur_cornflakes", + "stars": 0, + "forks": 2, + "star_fork_ratio": 0 + }, + { + "repo_name": "Herwey/CS-Notes", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "Parafix/R", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "stars", + "type": "UInt64" + }, + { + "name": "forks", + "type": "UInt64" + }, + { + "name": "star_fork_ratio", + "type": "Float64" + } + ], + "statistics": { + "elapsed": 0.130529988, + "rows_read": 13029662, + "bytes_read": 93945108 + }, + "executionTime": 0.235, + "requestId": "01KA4BBR7A0SA21CVE41NM31NJ", + "length": 794 + }, + "name": "pipe_31.pipe", + "question": { + "name": "pipe_31.pipe", + "content": "DESCRIPTION >\n top 10 reposistories by ratio between stars and forks\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n sum(event_type = 'ForkEvent') AS forks,\n sum(event_type = 'WatchEvent') AS stars,\n round(stars / forks, 3) AS ratio\n FROM github_events\n WHERE event_type IN ('ForkEvent', 'WatchEvent')\n GROUP BY repo_name\n ORDER BY forks DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 reposistories by ratio between stars and forks\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 reposistories by ratio between stars and forks\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b4f8c6eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.649, + "totalDuration": 18.868, + "tokens": { + "promptTokens": 9583, + "completionTokens": 1968, + "totalTokens": 11551 + } + }, + "error": null, + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 reposistories by ratio between stars and forks\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b4f8c6eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_31.pipe", + "question": { + "name": "pipe_31.pipe", + "content": "DESCRIPTION >\n top 10 reposistories by ratio between stars and forks\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n sum(event_type = 'ForkEvent') AS forks,\n sum(event_type = 'WatchEvent') AS stars,\n round(stars / forks, 3) AS ratio\n FROM github_events\n WHERE event_type IN ('ForkEvent', 'WatchEvent')\n GROUP BY repo_name\n ORDER BY forks DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 reposistories by ratio between stars and forks" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": "\nSELECT\n repo_name,\n sum(event_type = 'WatchEvent') AS stars,\n sum(event_type = 'ForkEvent') AS forks,\n sum(event_type = 'WatchEvent') / sum(event_type = 'ForkEvent') AS star_fork_ratio\nFROM github_events\nWHERE event_type IN ('WatchEvent', 'ForkEvent')\nGROUP BY repo_name\nHAVING sum(event_type = 'ForkEvent') > 0\nORDER BY star_fork_ratio DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "CHEF-KOCH/VSCode-Settings", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "Dataweekends/pong_reinforcement_learning", + "stars": 0, + "forks": 2, + "star_fork_ratio": 0 + }, + { + "repo_name": "PeterCxy/android_system_core", + "stars": 0, + "forks": 2, + "star_fork_ratio": 0 + }, + { + "repo_name": "Gforcex/OpenGraphic", + "stars": 0, + "forks": 34, + "star_fork_ratio": 0 + }, + { + "repo_name": "ZarinNegah/mtpbulksecret", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "GSA/digital.gov-design", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "aki270/aki52", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "c6burns/udp_in_ur_cornflakes", + "stars": 0, + "forks": 2, + "star_fork_ratio": 0 + }, + { + "repo_name": "Herwey/CS-Notes", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + }, + { + "repo_name": "Parafix/R", + "stars": 0, + "forks": 1, + "star_fork_ratio": 0 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "stars", + "type": "UInt64" + }, + { + "name": "forks", + "type": "UInt64" + }, + { + "name": "star_fork_ratio", + "type": "Float64" + } + ], + "statistics": { + "elapsed": 0.130529988, + "rows_read": 13029662, + "bytes_read": 93945108 + }, + "executionTime": 0.235, + "requestId": "01KA4BBR7A0SA21CVE41NM31NJ", + "length": 794 + }, + "name": "pipe_31.pipe", + "question": { + "name": "pipe_31.pipe", + "content": "DESCRIPTION >\n top 10 reposistories by ratio between stars and forks\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n sum(event_type = 'ForkEvent') AS forks,\n sum(event_type = 'WatchEvent') AS stars,\n round(stars / forks, 3) AS ratio\n FROM github_events\n WHERE event_type IN ('ForkEvent', 'WatchEvent')\n GROUP BY repo_name\n ORDER BY forks DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 reposistories by ratio between stars and forks\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 reposistories by ratio between stars and forks\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b4f8c6eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.649, + "totalDuration": 18.868, + "tokens": { + "promptTokens": 9583, + "completionTokens": 1968, + "totalTokens": 11551 + } + }, + "error": null + } + ] + }, + { + "sql": "\nSELECT\n sum((event_type = 'WatchEvent')) AS stars,\n sum((event_type = 'ForkEvent')) AS forks,\n CAST(sum((event_type = 'WatchEvent')) * 1.0 / sum((event_type = 'ForkEvent')) AS Decimal(20, 2)) AS ratio\nFROM github_events\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "stars": 7305112, + "forks": 5595482, + "ratio": 1.3 + } + ], + "meta": [ + { + "name": "stars", + "type": "UInt64" + }, + { + "name": "forks", + "type": "UInt64" + }, + { + "name": "ratio", + "type": "Decimal(20, 2)" + } + ], + "statistics": { + "elapsed": 0.030118126, + "rows_read": 200000000, + "bytes_read": 200004219 + }, + "executionTime": 0.134, + "requestId": "01KA4BBPCYCF327AZN6ZE7CW9G", + "length": 47 + }, + "name": "pipe_32.pipe", + "question": { + "name": "pipe_32.pipe", + "content": "DESCRIPTION >\n Total number of stars, forks, and ratio (rounded to 2 decimal places) between stars and forks\n\nNODE endpoint\nSQL >\n SELECT\n sum(event_type = 'WatchEvent') AS stars,\n sum(event_type = 'ForkEvent') AS forks,\n round(stars / forks, 2) AS ratio\n FROM github_events\n WHERE event_type IN ('ForkEvent', 'WatchEvent')\n\nTYPE endpoint", + "question": "Total number of stars, forks, and ratio (rounded to 2 decimal places) between stars and forks" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.291, + "totalDuration": 17.058, + "tokens": { + "promptTokens": 4594, + "completionTokens": 1795, + "totalTokens": 6389 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n sum((event_type = 'WatchEvent')) AS stars,\n sum((event_type = 'ForkEvent')) AS forks,\n CAST(sum((event_type = 'WatchEvent')) * 1.0 / sum((event_type = 'ForkEvent')) AS Decimal(20, 2)) AS ratio\nFROM github_events\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "stars": 7305112, + "forks": 5595482, + "ratio": 1.3 + } + ], + "meta": [ + { + "name": "stars", + "type": "UInt64" + }, + { + "name": "forks", + "type": "UInt64" + }, + { + "name": "ratio", + "type": "Decimal(20, 2)" + } + ], + "statistics": { + "elapsed": 0.030118126, + "rows_read": 200000000, + "bytes_read": 200004219 + }, + "executionTime": 0.134, + "requestId": "01KA4BBPCYCF327AZN6ZE7CW9G", + "length": 47 + }, + "name": "pipe_32.pipe", + "question": { + "name": "pipe_32.pipe", + "content": "DESCRIPTION >\n Total number of stars, forks, and ratio (rounded to 2 decimal places) between stars and forks\n\nNODE endpoint\nSQL >\n SELECT\n sum(event_type = 'WatchEvent') AS stars,\n sum(event_type = 'ForkEvent') AS forks,\n round(stars / forks, 2) AS ratio\n FROM github_events\n WHERE event_type IN ('ForkEvent', 'WatchEvent')\n\nTYPE endpoint", + "question": "Total number of stars, forks, and ratio (rounded to 2 decimal places) between stars and forks" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.291, + "totalDuration": 17.058, + "tokens": { + "promptTokens": 4594, + "completionTokens": 1795, + "totalTokens": 6389 + } + }, + "error": null + } + ] + }, + { + "sql": "\nSELECT COUNT(*) FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened' LIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "COUNT()": 8992824 + } + ], + "meta": [ + { + "name": "COUNT()", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.02717593, + "rows_read": 15208764, + "bytes_read": 30369155 + }, + "executionTime": 0.322, + "requestId": "01KA4BBB3CMGYC3Q54ESXJMBM9", + "length": 21 + }, + "name": "pipe_33.pipe", + "question": { + "name": "pipe_33.pipe", + "content": "DESCRIPTION >\n Total number of issues opened on GitHub\n\nNODE endpoint\nSQL >\n SELECT count() FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened'\n\nTYPE endpoint", + "question": "Total number of issues opened on GitHub" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.454, + "totalDuration": 5.3, + "tokens": { + "promptTokens": 4581, + "completionTokens": 599, + "totalTokens": 5180 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT COUNT(*) FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened' LIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "COUNT()": 8992824 + } + ], + "meta": [ + { + "name": "COUNT()", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.02717593, + "rows_read": 15208764, + "bytes_read": 30369155 + }, + "executionTime": 0.322, + "requestId": "01KA4BBB3CMGYC3Q54ESXJMBM9", + "length": 21 + }, + "name": "pipe_33.pipe", + "question": { + "name": "pipe_33.pipe", + "content": "DESCRIPTION >\n Total number of issues opened on GitHub\n\nNODE endpoint\nSQL >\n SELECT count() FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened'\n\nTYPE endpoint", + "question": "Total number of issues opened on GitHub" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.454, + "totalDuration": 5.3, + "tokens": { + "promptTokens": 4581, + "completionTokens": 599, + "totalTokens": 5180 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"The top 10 repositories by issue comment events\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The top 10 repositories by issue comment events\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3b4f953e811-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"The top 10 repositories by issue comment events\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"The top 10 repositories by issue comment events\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b3b4f953e811-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3b54992eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b57a82e811-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_34.pipe", + "question": { + "name": "pipe_34.pipe", + "content": "DESCRIPTION >\n The top 10 repositories by issue comment events\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE event_type = 'IssueCommentEvent' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"The top 10 repositories by issue comment events\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"The top 10 repositories by issue comment events\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b4f953e811-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"The top 10 repositories by issue comment events\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The top 10 repositories by issue comment events\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3b4f953e811-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b54992eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"The top 10 repositories by issue comment events\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b4f953e811-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_34.pipe", + "question": { + "name": "pipe_34.pipe", + "content": "DESCRIPTION >\n The top 10 repositories by issue comment events\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE event_type = 'IssueCommentEvent' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "The top 10 repositories by issue comment events" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"The top 10 repositories by issue comment events\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The top 10 repositories by issue comment events\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3b4f953e811-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b54992eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_34.pipe", + "question": { + "name": "pipe_34.pipe", + "content": "DESCRIPTION >\n The top 10 repositories by issue comment events\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE event_type = 'IssueCommentEvent' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"The top 10 repositories by issue comment events\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"The top 10 repositories by issue comment events\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b4f953e811-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"The top 10 repositories by issue comment events\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The top 10 repositories by issue comment events\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3b4f953e811-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"The top 10 repositories by issue comment events\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"The top 10 repositories by issue comment events\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b3b4f953e811-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3b54992eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b57a82e811-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_34.pipe", + "question": { + "name": "pipe_34.pipe", + "content": "DESCRIPTION >\n The top 10 repositories by issue comment events\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE event_type = 'IssueCommentEvent' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"The top 10 repositories by issue comment events\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"The top 10 repositories by issue comment events\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b4f953e811-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"The top 10 repositories by issue comment events\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"The top 10 repositories by issue comment events\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b3b4f953e811-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:09:50 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b3b54992eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:09:50 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n repo_name,\n countIf(event_type = 'IssueCommentEvent') AS num_comments,\n countIf(event_type = 'IssuesEvent' AND action = 'opened') AS num_issues,\n num_comments / num_issues AS ratio\nFROM github_events\nGROUP BY repo_name\nHAVING num_issues > 0\nORDER BY ratio DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "xen-org/xen-api", + "num_comments": 1567, + "num_issues": 1, + "ratio": 1567 + }, + { + "repo_name": "basho/rebar", + "num_comments": 312, + "num_issues": 1, + "ratio": 312 + }, + { + "repo_name": "scala/scala", + "num_comments": 159, + "num_issues": 1, + "ratio": 159 + }, + { + "repo_name": "gxa/gxa", + "num_comments": 168, + "num_issues": 2, + "ratio": 84 + }, + { + "repo_name": "tomdale/everyjs.com", + "num_comments": 83, + "num_issues": 1, + "ratio": 83 + }, + { + "repo_name": "zendframework/zf2", + "num_comments": 734, + "num_issues": 9, + "ratio": 81.55555555555556 + }, + { + "repo_name": "smcq/paisley", + "num_comments": 68, + "num_issues": 1, + "ratio": 68 + }, + { + "repo_name": "hibernate/hibernate-ogm", + "num_comments": 68, + "num_issues": 1, + "ratio": 68 + }, + { + "repo_name": "glqgamemaster/Gentle-Love-Quest", + "num_comments": 67, + "num_issues": 1, + "ratio": 67 + }, + { + "repo_name": "joomla/joomla-cms", + "num_comments": 131, + "num_issues": 2, + "ratio": 65.5 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "num_comments", + "type": "UInt64" + }, + { + "name": "num_issues", + "type": "UInt64" + }, + { + "name": "ratio", + "type": "Float64" + } + ], + "statistics": { + "elapsed": 1.491943547, + "rows_read": 200000000, + "bytes_read": 1668211274 + }, + "executionTime": 1.594, + "requestId": "01KA4BBCQ4J9DAMH6JDDAY7ARF", + "length": 802 + }, + "name": "pipe_35.pipe", + "question": { + "name": "pipe_35.pipe", + "content": "DESCRIPTION >\n top 10 repositories by ratio between issue comments and issues\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS comments,\n uniq(number) AS issues,\n round(comments / issues, 2) AS ratio\n FROM github_events\n WHERE event_type = 'IssueCommentEvent'\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 repositories by ratio between issue comments and issues" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.575, + "totalDuration": 7.144, + "tokens": { + "promptTokens": 4584, + "completionTokens": 880, + "totalTokens": 5464 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n repo_name,\n countIf(event_type = 'IssueCommentEvent') AS num_comments,\n countIf(event_type = 'IssuesEvent' AND action = 'opened') AS num_issues,\n num_comments / num_issues AS ratio\nFROM github_events\nGROUP BY repo_name\nHAVING num_issues > 0\nORDER BY ratio DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "xen-org/xen-api", + "num_comments": 1567, + "num_issues": 1, + "ratio": 1567 + }, + { + "repo_name": "basho/rebar", + "num_comments": 312, + "num_issues": 1, + "ratio": 312 + }, + { + "repo_name": "scala/scala", + "num_comments": 159, + "num_issues": 1, + "ratio": 159 + }, + { + "repo_name": "gxa/gxa", + "num_comments": 168, + "num_issues": 2, + "ratio": 84 + }, + { + "repo_name": "tomdale/everyjs.com", + "num_comments": 83, + "num_issues": 1, + "ratio": 83 + }, + { + "repo_name": "zendframework/zf2", + "num_comments": 734, + "num_issues": 9, + "ratio": 81.55555555555556 + }, + { + "repo_name": "smcq/paisley", + "num_comments": 68, + "num_issues": 1, + "ratio": 68 + }, + { + "repo_name": "hibernate/hibernate-ogm", + "num_comments": 68, + "num_issues": 1, + "ratio": 68 + }, + { + "repo_name": "glqgamemaster/Gentle-Love-Quest", + "num_comments": 67, + "num_issues": 1, + "ratio": 67 + }, + { + "repo_name": "joomla/joomla-cms", + "num_comments": 131, + "num_issues": 2, + "ratio": 65.5 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "num_comments", + "type": "UInt64" + }, + { + "name": "num_issues", + "type": "UInt64" + }, + { + "name": "ratio", + "type": "Float64" + } + ], + "statistics": { + "elapsed": 1.491943547, + "rows_read": 200000000, + "bytes_read": 1668211274 + }, + "executionTime": 1.594, + "requestId": "01KA4BBCQ4J9DAMH6JDDAY7ARF", + "length": 802 + }, + "name": "pipe_35.pipe", + "question": { + "name": "pipe_35.pipe", + "content": "DESCRIPTION >\n top 10 repositories by ratio between issue comments and issues\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS comments,\n uniq(number) AS issues,\n round(comments / issues, 2) AS ratio\n FROM github_events\n WHERE event_type = 'IssueCommentEvent'\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 repositories by ratio between issue comments and issues" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.575, + "totalDuration": 7.144, + "tokens": { + "promptTokens": 4584, + "completionTokens": 880, + "totalTokens": 5464 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6b3714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b43c6b3714ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43d2b926188-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d7d8014ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_36.pipe", + "question": { + "name": "pipe_36.pipe", + "content": "DESCRIPTION >\n Top 10 GitHub issues (repo + issue number) by how many comments have been created\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n number,\n count() AS comments\n FROM github_events\n WHERE (event_type = 'IssueCommentEvent') AND (action = 'created')\n GROUP BY\n repo_name,\n number\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 GitHub issues (repo + issue number) by how many comments have been created\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6b3714ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6b3714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d2b926188-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6b3714ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_36.pipe", + "question": { + "name": "pipe_36.pipe", + "content": "DESCRIPTION >\n Top 10 GitHub issues (repo + issue number) by how many comments have been created\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n number,\n count() AS comments\n FROM github_events\n WHERE (event_type = 'IssueCommentEvent') AND (action = 'created')\n GROUP BY\n repo_name,\n number\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 GitHub issues (repo + issue number) by how many comments have been created" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6b3714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d2b926188-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_36.pipe", + "question": { + "name": "pipe_36.pipe", + "content": "DESCRIPTION >\n Top 10 GitHub issues (repo + issue number) by how many comments have been created\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n number,\n count() AS comments\n FROM github_events\n WHERE (event_type = 'IssueCommentEvent') AND (action = 'created')\n GROUP BY\n repo_name,\n number\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 GitHub issues (repo + issue number) by how many comments have been created\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6b3714ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6b3714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b43c6b3714ce-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43d2b926188-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d7d8014ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_36.pipe", + "question": { + "name": "pipe_36.pipe", + "content": "DESCRIPTION >\n Top 10 GitHub issues (repo + issue number) by how many comments have been created\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n number,\n count() AS comments\n FROM github_events\n WHERE (event_type = 'IssueCommentEvent') AND (action = 'created')\n GROUP BY\n repo_name,\n number\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 GitHub issues (repo + issue number) by how many comments have been created\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6b3714ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 GitHub issues (repo + issue number) by how many comments have been created\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6b3714ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d2b926188-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6ce5874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b43c6ce5874f-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43cec5014ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d183f4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_37.pipe", + "question": { + "name": "pipe_37.pipe", + "content": "DESCRIPTION >\n TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n number,\n count() AS comments,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'IssueCommentEvent') AND (action = 'created') AND (number > 10)\n GROUP BY\n repo_name,\n number\n HAVING authors >= 10\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6ce5874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6ce5874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43cec5014ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6ce5874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_37.pipe", + "question": { + "name": "pipe_37.pipe", + "content": "DESCRIPTION >\n TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n number,\n count() AS comments,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'IssueCommentEvent') AND (action = 'created') AND (number > 10)\n GROUP BY\n repo_name,\n number\n HAVING authors >= 10\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6ce5874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43cec5014ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_37.pipe", + "question": { + "name": "pipe_37.pipe", + "content": "DESCRIPTION >\n TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n number,\n count() AS comments,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'IssueCommentEvent') AND (action = 'created') AND (number > 10)\n GROUP BY\n repo_name,\n number\n HAVING authors >= 10\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6ce5874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6ce5874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b43c6ce5874f-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43cec5014ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d183f4fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_37.pipe", + "question": { + "name": "pipe_37.pipe", + "content": "DESCRIPTION >\n TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n number,\n count() AS comments,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'IssueCommentEvent') AND (action = 'created') AND (number > 10)\n GROUP BY\n repo_name,\n number\n HAVING authors >= 10\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6ce5874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"TTop 10 GitHub issues (repo + issue number > 10) by how many comments have been created. Let's also count the number of comment authors and add a threshold of >= 10\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6ce5874f-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43cec5014ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c687eeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b43c687eeb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43cbef39a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d0a86eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_38.pipe", + "question": { + "name": "pipe_38.pipe", + "content": "DESCRIPTION >\n Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE body ILIKE '%tensorflow%' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c687eeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c687eeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43cbef39a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c687eeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_38.pipe", + "question": { + "name": "pipe_38.pipe", + "content": "DESCRIPTION >\n Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE body ILIKE '%tensorflow%' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c687eeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43cbef39a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_38.pipe", + "question": { + "name": "pipe_38.pipe", + "content": "DESCRIPTION >\n Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE body ILIKE '%tensorflow%' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c687eeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c687eeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b43c687eeb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43cbef39a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d0a86eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_38.pipe", + "question": { + "name": "pipe_38.pipe", + "content": "DESCRIPTION >\n Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\n\nNODE endpoint\nSQL >\n SELECT repo_name, count() FROM github_events WHERE body ILIKE '%tensorflow%' GROUP BY repo_name ORDER BY count() DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c687eeb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 Repositories with most events talking about tensorflow. Return the repository name and the number of events matching.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c687eeb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43cbef39a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "SELECT\n repo_name,\n count() AS num_commit_comments\nFROM github_events\nWHERE event_type = 'CommitCommentEvent'\nGROUP BY repo_name\nORDER BY num_commit_comments DESC\nLIMIT 10", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "dcos/dcos", + "num_commit_comments": 99250 + }, + { + "repo_name": "siggetest/githubtest", + "num_commit_comments": 52171 + }, + { + "repo_name": "NREL/EnergyPlus", + "num_commit_comments": 47886 + }, + { + "repo_name": "bambootest-bot/githubtest", + "num_commit_comments": 46876 + }, + { + "repo_name": "w4ctech/front-end-rss", + "num_commit_comments": 35958 + }, + { + "repo_name": "xamarin/xamarin-macios", + "num_commit_comments": 30631 + }, + { + "repo_name": "zeit-github-test/github-e2e-tests-dev", + "num_commit_comments": 28463 + }, + { + "repo_name": "miabot/galleries.csv", + "num_commit_comments": 18622 + }, + { + "repo_name": "zeit-github-test/github-e2e-tests-dev-alias-v2-without-alias", + "num_commit_comments": 16107 + }, + { + "repo_name": "zeit-github-test/github-e2e-tests-dev-alias-v2-with-alias", + "num_commit_comments": 16077 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "num_commit_comments", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.098585295, + "rows_read": 6792623, + "bytes_read": 59320521 + }, + "executionTime": 0.203, + "requestId": "01KA4BBXVKQXFQ0FKSAJ7Z0WAS", + "length": 737 + }, + "name": "pipe_39.pipe", + "question": { + "name": "pipe_39.pipe", + "content": "DESCRIPTION >\n top 10 repositories by the number of commit comments\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS comments\n FROM github_events\n WHERE event_type = 'CommitCommentEvent'\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 repositories by the number of commit comments\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 repositories by the number of commit comments\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6df54fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.603, + "totalDuration": 2.982, + "tokens": { + "promptTokens": 9577, + "completionTokens": 330, + "totalTokens": 9907 + } + }, + "error": null, + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 repositories by the number of commit comments\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6df54fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_39.pipe", + "question": { + "name": "pipe_39.pipe", + "content": "DESCRIPTION >\n top 10 repositories by the number of commit comments\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS comments\n FROM github_events\n WHERE event_type = 'CommitCommentEvent'\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 repositories by the number of commit comments" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": "SELECT\n repo_name,\n count() AS num_commit_comments\nFROM github_events\nWHERE event_type = 'CommitCommentEvent'\nGROUP BY repo_name\nORDER BY num_commit_comments DESC\nLIMIT 10", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "dcos/dcos", + "num_commit_comments": 99250 + }, + { + "repo_name": "siggetest/githubtest", + "num_commit_comments": 52171 + }, + { + "repo_name": "NREL/EnergyPlus", + "num_commit_comments": 47886 + }, + { + "repo_name": "bambootest-bot/githubtest", + "num_commit_comments": 46876 + }, + { + "repo_name": "w4ctech/front-end-rss", + "num_commit_comments": 35958 + }, + { + "repo_name": "xamarin/xamarin-macios", + "num_commit_comments": 30631 + }, + { + "repo_name": "zeit-github-test/github-e2e-tests-dev", + "num_commit_comments": 28463 + }, + { + "repo_name": "miabot/galleries.csv", + "num_commit_comments": 18622 + }, + { + "repo_name": "zeit-github-test/github-e2e-tests-dev-alias-v2-without-alias", + "num_commit_comments": 16107 + }, + { + "repo_name": "zeit-github-test/github-e2e-tests-dev-alias-v2-with-alias", + "num_commit_comments": 16077 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "num_commit_comments", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.098585295, + "rows_read": 6792623, + "bytes_read": 59320521 + }, + "executionTime": 0.203, + "requestId": "01KA4BBXVKQXFQ0FKSAJ7Z0WAS", + "length": 737 + }, + "name": "pipe_39.pipe", + "question": { + "name": "pipe_39.pipe", + "content": "DESCRIPTION >\n top 10 repositories by the number of commit comments\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS comments\n FROM github_events\n WHERE event_type = 'CommitCommentEvent'\n GROUP BY repo_name\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"top 10 repositories by the number of commit comments\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"top 10 repositories by the number of commit comments\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6df54fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.603, + "totalDuration": 2.982, + "tokens": { + "promptTokens": 9577, + "completionTokens": 330, + "totalTokens": 9907 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6e3e9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b43c6e3e9a2e-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43caed44fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d0d5e874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_40.pipe", + "question": { + "name": "pipe_40.pipe", + "content": "DESCRIPTION >\n Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\n\nNODE endpoint\nSQL >\n SELECT\n concat('https://github.com/', repo_name, '/commit/', commit_id) AS URL,\n count() AS comments,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'CommitCommentEvent') AND notEmpty(commit_id)\n GROUP BY\n repo_name,\n commit_id\n HAVING authors >= 10\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6e3e9a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6e3e9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43caed44fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6e3e9a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_40.pipe", + "question": { + "name": "pipe_40.pipe", + "content": "DESCRIPTION >\n Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\n\nNODE endpoint\nSQL >\n SELECT\n concat('https://github.com/', repo_name, '/commit/', commit_id) AS URL,\n count() AS comments,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'CommitCommentEvent') AND notEmpty(commit_id)\n GROUP BY\n repo_name,\n commit_id\n HAVING authors >= 10\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6e3e9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43caed44fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_40.pipe", + "question": { + "name": "pipe_40.pipe", + "content": "DESCRIPTION >\n Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\n\nNODE endpoint\nSQL >\n SELECT\n concat('https://github.com/', repo_name, '/commit/', commit_id) AS URL,\n count() AS comments,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'CommitCommentEvent') AND notEmpty(commit_id)\n GROUP BY\n repo_name,\n commit_id\n HAVING authors >= 10\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6e3e9a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6e3e9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b43c6e3e9a2e-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43caed44fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43d0d5e874f-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_40.pipe", + "question": { + "name": "pipe_40.pipe", + "content": "DESCRIPTION >\n Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\n\nNODE endpoint\nSQL >\n SELECT\n concat('https://github.com/', repo_name, '/commit/', commit_id) AS URL,\n count() AS comments,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'CommitCommentEvent') AND notEmpty(commit_id)\n GROUP BY\n repo_name,\n commit_id\n HAVING authors >= 10\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43c6e3e9a2e-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 commits ordered by the count of commit events; include only commits with ≥ 10 distinct commenters and return full commit url, total comments, and unique authors\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b43c6e3e9a2e-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:12 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b43caed44fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:12 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n 'https://github.com/' || repo_name || '/pull/' || CAST(number AS String) AS pr_url,\n uniqExact(actor_login) AS unique_authors\nFROM github_events\nWHERE event_type = 'PullRequestReviewCommentEvent'\nGROUP BY repo_name, number\nORDER BY unique_authors DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "pr_url": "https://github.com/tc39/ecma262/pull/1062", + "unique_authors": 30 + }, + { + "pr_url": "https://github.com/iojs/io.js/pull/1457", + "unique_authors": 19 + }, + { + "pr_url": "https://github.com/JuliaLang/julialang.github.com/pull/437", + "unique_authors": 17 + }, + { + "pr_url": "https://github.com/tgstation/tgstation/pull/34916", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/zephyrproject-rtos/zephyr/pull/24152", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/symfony/recipes/pull/466", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/symfony/symfony/pull/24411", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/tgstation/tgstation/pull/40312", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/zephyrproject-rtos/zephyr/pull/27185", + "unique_authors": 15 + }, + { + "pr_url": "https://github.com/jquery/jquery.org/pull/105", + "unique_authors": 15 + } + ], + "meta": [ + { + "name": "pr_url", + "type": "String" + }, + { + "name": "unique_authors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.076705809, + "rows_read": 3947090, + "bytes_read": 36783105 + }, + "executionTime": 0.181, + "requestId": "01KA4BCJZ6GAXKA91WAH84RJC3", + "length": 820 + }, + "name": "pipe_41.pipe", + "question": { + "name": "pipe_41.pipe", + "content": "DESCRIPTION >\n Top 10 most tough code reviews (that is, PRs with the most authors involved creating comments). Return the full URL of the PR, and the number of unique authors.\n\nNODE endpoint\nSQL >\n SELECT\n concat('https://github.com/', repo_name, '/pull/', toString(number)) AS URL,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'PullRequestReviewCommentEvent') AND (action = 'created')\n GROUP BY\n repo_name,\n number\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 most tough code reviews (that is, PRs with the most authors involved creating comments). Return the full URL of the PR, and the number of unique authors." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.356, + "totalDuration": 18.913, + "tokens": { + "promptTokens": 4609, + "completionTokens": 2098, + "totalTokens": 6707 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n 'https://github.com/' || repo_name || '/pull/' || CAST(number AS String) AS pr_url,\n uniqExact(actor_login) AS unique_authors\nFROM github_events\nWHERE event_type = 'PullRequestReviewCommentEvent'\nGROUP BY repo_name, number\nORDER BY unique_authors DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "pr_url": "https://github.com/tc39/ecma262/pull/1062", + "unique_authors": 30 + }, + { + "pr_url": "https://github.com/iojs/io.js/pull/1457", + "unique_authors": 19 + }, + { + "pr_url": "https://github.com/JuliaLang/julialang.github.com/pull/437", + "unique_authors": 17 + }, + { + "pr_url": "https://github.com/tgstation/tgstation/pull/34916", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/zephyrproject-rtos/zephyr/pull/24152", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/symfony/recipes/pull/466", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/symfony/symfony/pull/24411", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/tgstation/tgstation/pull/40312", + "unique_authors": 16 + }, + { + "pr_url": "https://github.com/zephyrproject-rtos/zephyr/pull/27185", + "unique_authors": 15 + }, + { + "pr_url": "https://github.com/jquery/jquery.org/pull/105", + "unique_authors": 15 + } + ], + "meta": [ + { + "name": "pr_url", + "type": "String" + }, + { + "name": "unique_authors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.076705809, + "rows_read": 3947090, + "bytes_read": 36783105 + }, + "executionTime": 0.181, + "requestId": "01KA4BCJZ6GAXKA91WAH84RJC3", + "length": 820 + }, + "name": "pipe_41.pipe", + "question": { + "name": "pipe_41.pipe", + "content": "DESCRIPTION >\n Top 10 most tough code reviews (that is, PRs with the most authors involved creating comments). Return the full URL of the PR, and the number of unique authors.\n\nNODE endpoint\nSQL >\n SELECT\n concat('https://github.com/', repo_name, '/pull/', toString(number)) AS URL,\n uniq(actor_login) AS authors\n FROM github_events\n WHERE (event_type = 'PullRequestReviewCommentEvent') AND (action = 'created')\n GROUP BY\n repo_name,\n number\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 most tough code reviews (that is, PRs with the most authors involved creating comments). Return the full URL of the PR, and the number of unique authors." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.356, + "totalDuration": 18.913, + "tokens": { + "promptTokens": 4609, + "completionTokens": 2098, + "totalTokens": 6707 + } + }, + "error": null + } + ] + }, + { + "sql": "\nSELECT\n actor_login,\n count() AS pushes\nFROM github_events\nWHERE event_type = 'PushEvent'\nGROUP BY actor_login\nORDER BY pushes DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "actor_login": "LombiqBot", + "pushes": 3507260 + }, + { + "actor_login": "frankbaele", + "pushes": 369489 + }, + { + "actor_login": "chuan12", + "pushes": 356449 + }, + { + "actor_login": "ItzLevvie", + "pushes": 276592 + }, + { + "actor_login": "geos4s", + "pushes": 262170 + }, + { + "actor_login": "applepaper", + "pushes": 257240 + }, + { + "actor_login": "github-actions[bot]", + "pushes": 232538 + }, + { + "actor_login": "datarods-svc", + "pushes": 198853 + }, + { + "actor_login": "c1d5dc29-94f0-4b46-bc0a-397a2885eade", + "pushes": 180627 + }, + { + "actor_login": "renovate[bot]", + "pushes": 171382 + } + ], + "meta": [ + { + "name": "actor_login", + "type": "LowCardinality(String)" + }, + { + "name": "pushes", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.150788781, + "rows_read": 75572830, + "bytes_read": 238309784 + }, + "executionTime": 0.256, + "requestId": "01KA4BC34HTNYN5BTRV5NZWRD6", + "length": 483 + }, + "name": "pipe_42.pipe", + "question": { + "name": "pipe_42.pipe", + "content": "DESCRIPTION >\n Top 10 authors with the most pushes\n\nNODE endpoint\nSQL >\n SELECT\n actor_login,\n count() AS c\n FROM github_events\n WHERE event_type = 'PushEvent'\n GROUP BY actor_login\n ORDER BY c DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 authors with the most pushes" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.653, + "totalDuration": 2.7, + "tokens": { + "promptTokens": 4581, + "completionTokens": 237, + "totalTokens": 4818 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n actor_login,\n count() AS pushes\nFROM github_events\nWHERE event_type = 'PushEvent'\nGROUP BY actor_login\nORDER BY pushes DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "actor_login": "LombiqBot", + "pushes": 3507260 + }, + { + "actor_login": "frankbaele", + "pushes": 369489 + }, + { + "actor_login": "chuan12", + "pushes": 356449 + }, + { + "actor_login": "ItzLevvie", + "pushes": 276592 + }, + { + "actor_login": "geos4s", + "pushes": 262170 + }, + { + "actor_login": "applepaper", + "pushes": 257240 + }, + { + "actor_login": "github-actions[bot]", + "pushes": 232538 + }, + { + "actor_login": "datarods-svc", + "pushes": 198853 + }, + { + "actor_login": "c1d5dc29-94f0-4b46-bc0a-397a2885eade", + "pushes": 180627 + }, + { + "actor_login": "renovate[bot]", + "pushes": 171382 + } + ], + "meta": [ + { + "name": "actor_login", + "type": "LowCardinality(String)" + }, + { + "name": "pushes", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.150788781, + "rows_read": 75572830, + "bytes_read": 238309784 + }, + "executionTime": 0.256, + "requestId": "01KA4BC34HTNYN5BTRV5NZWRD6", + "length": 483 + }, + "name": "pipe_42.pipe", + "question": { + "name": "pipe_42.pipe", + "content": "DESCRIPTION >\n Top 10 authors with the most pushes\n\nNODE endpoint\nSQL >\n SELECT\n actor_login,\n count() AS c\n FROM github_events\n WHERE event_type = 'PushEvent'\n GROUP BY actor_login\n ORDER BY c DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 authors with the most pushes" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.653, + "totalDuration": 2.7, + "tokens": { + "promptTokens": 4581, + "completionTokens": 237, + "totalTokens": 4818 + } + }, + "error": null + } + ] + }, + { + "sql": "\nSELECT\n substringIndex(repo_name, '/', 1) AS owner,\n count() AS stars\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY owner\nORDER BY stars DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "owner": "vuejs", + "stars": 108982 + }, + { + "owner": "sindresorhus", + "stars": 93511 + }, + { + "owner": "tensorflow", + "stars": 86682 + }, + { + "owner": "shadowsocks", + "stars": 47997 + }, + { + "owner": "square", + "stars": 46713 + }, + { + "owner": "reactjs", + "stars": 39799 + }, + { + "owner": "yahoo", + "stars": 36455 + }, + { + "owner": "yarnpkg", + "stars": 31480 + }, + { + "owner": "spring-projects", + "stars": 30189 + }, + { + "owner": "zeit", + "stars": 27822 + } + ], + "meta": [ + { + "name": "owner", + "type": "LowCardinality(String)" + }, + { + "name": "stars", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.032048581, + "rows_read": 7321600, + "bytes_read": 35699881 + }, + "executionTime": 0.138, + "requestId": "01KA4BC8BAVPDZBRV3P8MERZZ3", + "length": 354 + }, + "name": "pipe_43.pipe", + "question": { + "name": "pipe_43.pipe", + "content": "DESCRIPTION >\n Top 10 users/organizations by the number of stars (get the organization name from the repo_name)\n\nNODE endpoint\nSQL >\n SELECT\n lower(substring(repo_name, 1, position(repo_name, '/'))) AS org,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY org\n ORDER BY stars DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 users/organizations by the number of stars (get the organization name from the repo_name)\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 users/organizations by the number of stars (get the organization name from the repo_name)\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4603d11f50d-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:18 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.685, + "totalDuration": 7.947, + "tokens": { + "promptTokens": 9598, + "completionTokens": 921, + "totalTokens": 10519 + } + }, + "error": null, + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 users/organizations by the number of stars (get the organization name from the repo_name)\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4603d11f50d-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:18 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_43.pipe", + "question": { + "name": "pipe_43.pipe", + "content": "DESCRIPTION >\n Top 10 users/organizations by the number of stars (get the organization name from the repo_name)\n\nNODE endpoint\nSQL >\n SELECT\n lower(substring(repo_name, 1, position(repo_name, '/'))) AS org,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY org\n ORDER BY stars DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 users/organizations by the number of stars (get the organization name from the repo_name)" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": "\nSELECT\n substringIndex(repo_name, '/', 1) AS owner,\n count() AS stars\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY owner\nORDER BY stars DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "owner": "vuejs", + "stars": 108982 + }, + { + "owner": "sindresorhus", + "stars": 93511 + }, + { + "owner": "tensorflow", + "stars": 86682 + }, + { + "owner": "shadowsocks", + "stars": 47997 + }, + { + "owner": "square", + "stars": 46713 + }, + { + "owner": "reactjs", + "stars": 39799 + }, + { + "owner": "yahoo", + "stars": 36455 + }, + { + "owner": "yarnpkg", + "stars": 31480 + }, + { + "owner": "spring-projects", + "stars": 30189 + }, + { + "owner": "zeit", + "stars": 27822 + } + ], + "meta": [ + { + "name": "owner", + "type": "LowCardinality(String)" + }, + { + "name": "stars", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.032048581, + "rows_read": 7321600, + "bytes_read": 35699881 + }, + "executionTime": 0.138, + "requestId": "01KA4BC8BAVPDZBRV3P8MERZZ3", + "length": 354 + }, + "name": "pipe_43.pipe", + "question": { + "name": "pipe_43.pipe", + "content": "DESCRIPTION >\n Top 10 users/organizations by the number of stars (get the organization name from the repo_name)\n\nNODE endpoint\nSQL >\n SELECT\n lower(substring(repo_name, 1, position(repo_name, '/'))) AS org,\n count() AS stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY org\n ORDER BY stars DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 users/organizations by the number of stars (get the organization name from the repo_name)\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 users/organizations by the number of stars (get the organization name from the repo_name)\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4603d11f50d-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:18 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.685, + "totalDuration": 7.947, + "tokens": { + "promptTokens": 9598, + "completionTokens": 921, + "totalTokens": 10519 + } + }, + "error": null + } + ] + }, + { + "sql": "\nSELECT\n substringIndex(repo_name, '/', 1) AS org_name,\n count(DISTINCT repo_name) AS repo_count\nFROM github_events\nWHERE repo_name != ''\nGROUP BY org_name\nORDER BY repo_count DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "org_name": "ideatest1", + "repo_count": 47253 + }, + { + "org_name": "GITenberg", + "repo_count": 46941 + }, + { + "org_name": "gitpan", + "repo_count": 35835 + }, + { + "org_name": "gitter-badger", + "repo_count": 19893 + }, + { + "org_name": "circle-test-organization", + "repo_count": 18440 + }, + { + "org_name": "octokit-net-test", + "repo_count": 16267 + }, + { + "org_name": "chepullreq3", + "repo_count": 15250 + }, + { + "org_name": "chepullreq1", + "repo_count": 14795 + }, + { + "org_name": "chepullreq2", + "repo_count": 12533 + }, + { + "org_name": "omar9483", + "repo_count": 12345 + } + ], + "meta": [ + { + "name": "org_name", + "type": "LowCardinality(String)" + }, + { + "name": "repo_count", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 1.52718555, + "rows_read": 200000000, + "bytes_read": 1268178829 + }, + "executionTime": 1.641, + "requestId": "01KA4BCDCFA358Q2PCY7D3Q8QP", + "length": 469 + }, + "name": "pipe_44.pipe", + "question": { + "name": "pipe_44.pipe", + "content": "DESCRIPTION >\n Top 10 organizations by the number of repositories (get the organization name from the repo_name)\n\nNODE endpoint\nSQL >\n SELECT\n lower(substring(repo_name, 1, position(repo_name, '/'))) AS org,\n uniq(repo_name) AS repos\n FROM\n (\n SELECT repo_name\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING count() >= 10\n )\n GROUP BY org\n ORDER BY repos DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 organizations by the number of repositories (get the organization name from the repo_name)" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.664, + "totalDuration": 13.193, + "tokens": { + "promptTokens": 4592, + "completionTokens": 1359, + "totalTokens": 5951 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n substringIndex(repo_name, '/', 1) AS org_name,\n count(DISTINCT repo_name) AS repo_count\nFROM github_events\nWHERE repo_name != ''\nGROUP BY org_name\nORDER BY repo_count DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "org_name": "ideatest1", + "repo_count": 47253 + }, + { + "org_name": "GITenberg", + "repo_count": 46941 + }, + { + "org_name": "gitpan", + "repo_count": 35835 + }, + { + "org_name": "gitter-badger", + "repo_count": 19893 + }, + { + "org_name": "circle-test-organization", + "repo_count": 18440 + }, + { + "org_name": "octokit-net-test", + "repo_count": 16267 + }, + { + "org_name": "chepullreq3", + "repo_count": 15250 + }, + { + "org_name": "chepullreq1", + "repo_count": 14795 + }, + { + "org_name": "chepullreq2", + "repo_count": 12533 + }, + { + "org_name": "omar9483", + "repo_count": 12345 + } + ], + "meta": [ + { + "name": "org_name", + "type": "LowCardinality(String)" + }, + { + "name": "repo_count", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 1.52718555, + "rows_read": 200000000, + "bytes_read": 1268178829 + }, + "executionTime": 1.641, + "requestId": "01KA4BCDCFA358Q2PCY7D3Q8QP", + "length": 469 + }, + "name": "pipe_44.pipe", + "question": { + "name": "pipe_44.pipe", + "content": "DESCRIPTION >\n Top 10 organizations by the number of repositories (get the organization name from the repo_name)\n\nNODE endpoint\nSQL >\n SELECT\n lower(substring(repo_name, 1, position(repo_name, '/'))) AS org,\n uniq(repo_name) AS repos\n FROM\n (\n SELECT repo_name\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n HAVING count() >= 10\n )\n GROUP BY org\n ORDER BY repos DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 organizations by the number of repositories (get the organization name from the repo_name)" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.664, + "totalDuration": 13.193, + "tokens": { + "promptTokens": 4592, + "completionTokens": 1359, + "totalTokens": 5951 + } + }, + "error": null + } + ] + }, + { + "sql": "\nSELECT\n repo_name,\n count() AS pr_count,\n uniqExact(actor_login) AS unique_authors,\n sum(additions) AS total_adds,\n sum(deletions) AS total_dels\nFROM github_events\nWHERE event_type = 'PullRequestEvent'\n AND action = 'opened'\n AND additions < 10000\n AND deletions < 10000\nGROUP BY repo_name\nORDER BY sum(additions) + sum(deletions) DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "everypolitician/everypolitician-data", + "pr_count": 12848, + "unique_authors": 3, + "total_adds": 5215610, + "total_dels": 5332897 + }, + { + "repo_name": "shuyangzhou/liferay-portal", + "pr_count": 2674, + "unique_authors": 41, + "total_adds": 4593360, + "total_dels": 2703679 + }, + { + "repo_name": "github-api-test-org/jenkins", + "pr_count": 687, + "unique_authors": 22, + "total_adds": 5102557, + "total_dels": 133042 + }, + { + "repo_name": "jsdelivr/jsdelivr", + "pr_count": 3772, + "unique_authors": 187, + "total_adds": 4582518, + "total_dels": 2122 + }, + { + "repo_name": "quanzhanying/jdstore", + "pr_count": 2206, + "unique_authors": 429, + "total_adds": 3713698, + "total_dels": 61341 + }, + { + "repo_name": "sergiogonzalez/liferay-portal", + "pr_count": 1696, + "unique_authors": 69, + "total_adds": 2097746, + "total_dels": 1234784 + }, + { + "repo_name": "tensorflow/tensorflow", + "pr_count": 4544, + "unique_authors": 715, + "total_adds": 2308746, + "total_dels": 847016 + }, + { + "repo_name": "rust-lang/rust", + "pr_count": 13344, + "unique_authors": 703, + "total_adds": 1933149, + "total_dels": 1153554 + }, + { + "repo_name": "kubernetes/kubernetes", + "pr_count": 11188, + "unique_authors": 1034, + "total_adds": 1976945, + "total_dels": 1014334 + }, + { + "repo_name": "learn-co-students/tic-tac-toe-rb-v-000", + "pr_count": 1190, + "unique_authors": 590, + "total_adds": 2663818, + "total_dels": 1516 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "pr_count", + "type": "UInt64" + }, + { + "name": "unique_authors", + "type": "UInt64" + }, + { + "name": "total_adds", + "type": "UInt64" + }, + { + "name": "total_dels", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.20590824, + "rows_read": 18340176, + "bytes_read": 270047065 + }, + "executionTime": 0.311, + "requestId": "01KA4BC8KRE5RNGAPYG0TMNZQG", + "length": 1198 + }, + "name": "pipe_45.pipe", + "question": { + "name": "pipe_45.pipe", + "content": "DESCRIPTION >\n top 10 repos ranked by total code churn (adds + dels) from pull requests opened\n only include PRs with <10 000 adds & <10 000 dels. return repo, pr count, unique authors, total adds, total dels\n\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS prs,\n uniq(actor_login) AS authors,\n sum(additions) AS adds,\n sum(deletions) AS dels\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened') AND (additions < 10000) AND (deletions < 10000)\n GROUP BY repo_name\n ORDER BY adds + dels DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 repos ranked by total code churn (adds + dels) from pull requests opened\n only include PRs with <10 000 adds & <10 000 dels. return repo, pr count, unique authors, total adds, total dels" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.452, + "totalDuration": 8.304, + "tokens": { + "promptTokens": 4624, + "completionTokens": 901, + "totalTokens": 5525 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n repo_name,\n count() AS pr_count,\n uniqExact(actor_login) AS unique_authors,\n sum(additions) AS total_adds,\n sum(deletions) AS total_dels\nFROM github_events\nWHERE event_type = 'PullRequestEvent'\n AND action = 'opened'\n AND additions < 10000\n AND deletions < 10000\nGROUP BY repo_name\nORDER BY sum(additions) + sum(deletions) DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "everypolitician/everypolitician-data", + "pr_count": 12848, + "unique_authors": 3, + "total_adds": 5215610, + "total_dels": 5332897 + }, + { + "repo_name": "shuyangzhou/liferay-portal", + "pr_count": 2674, + "unique_authors": 41, + "total_adds": 4593360, + "total_dels": 2703679 + }, + { + "repo_name": "github-api-test-org/jenkins", + "pr_count": 687, + "unique_authors": 22, + "total_adds": 5102557, + "total_dels": 133042 + }, + { + "repo_name": "jsdelivr/jsdelivr", + "pr_count": 3772, + "unique_authors": 187, + "total_adds": 4582518, + "total_dels": 2122 + }, + { + "repo_name": "quanzhanying/jdstore", + "pr_count": 2206, + "unique_authors": 429, + "total_adds": 3713698, + "total_dels": 61341 + }, + { + "repo_name": "sergiogonzalez/liferay-portal", + "pr_count": 1696, + "unique_authors": 69, + "total_adds": 2097746, + "total_dels": 1234784 + }, + { + "repo_name": "tensorflow/tensorflow", + "pr_count": 4544, + "unique_authors": 715, + "total_adds": 2308746, + "total_dels": 847016 + }, + { + "repo_name": "rust-lang/rust", + "pr_count": 13344, + "unique_authors": 703, + "total_adds": 1933149, + "total_dels": 1153554 + }, + { + "repo_name": "kubernetes/kubernetes", + "pr_count": 11188, + "unique_authors": 1034, + "total_adds": 1976945, + "total_dels": 1014334 + }, + { + "repo_name": "learn-co-students/tic-tac-toe-rb-v-000", + "pr_count": 1190, + "unique_authors": 590, + "total_adds": 2663818, + "total_dels": 1516 + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + }, + { + "name": "pr_count", + "type": "UInt64" + }, + { + "name": "unique_authors", + "type": "UInt64" + }, + { + "name": "total_adds", + "type": "UInt64" + }, + { + "name": "total_dels", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.20590824, + "rows_read": 18340176, + "bytes_read": 270047065 + }, + "executionTime": 0.311, + "requestId": "01KA4BC8KRE5RNGAPYG0TMNZQG", + "length": 1198 + }, + "name": "pipe_45.pipe", + "question": { + "name": "pipe_45.pipe", + "content": "DESCRIPTION >\n top 10 repos ranked by total code churn (adds + dels) from pull requests opened\n only include PRs with <10 000 adds & <10 000 dels. return repo, pr count, unique authors, total adds, total dels\n\n\nNODE endpoint\nSQL >\n SELECT\n repo_name,\n count() AS prs,\n uniq(actor_login) AS authors,\n sum(additions) AS adds,\n sum(deletions) AS dels\n FROM github_events\n WHERE (event_type = 'PullRequestEvent') AND (action = 'opened') AND (additions < 10000) AND (deletions < 10000)\n GROUP BY repo_name\n ORDER BY adds + dels DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 repos ranked by total code churn (adds + dels) from pull requests opened\n only include PRs with <10 000 adds & <10 000 dels. return repo, pr count, unique authors, total adds, total dels" + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.452, + "totalDuration": 8.304, + "tokens": { + "promptTokens": 4624, + "completionTokens": 901, + "totalTokens": 5525 + } + }, + "error": null + } + ] + }, + { + "sql": "\nSELECT\n actor_login AS author,\n count(*) AS num_comments,\n countDistinct(repo_name) AS unique_repos,\n countDistinct(tuple(repo_name, number)) AS unique_prs\nFROM github_events\nWHERE event_type = 'PullRequestReviewCommentEvent' AND action = 'created'\nGROUP BY actor_login\nORDER BY num_comments DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "author": "houndci-bot", + "num_comments": 62390, + "unique_repos": 530, + "unique_prs": 5115 + }, + { + "author": "houndci", + "num_comments": 54995, + "unique_repos": 639, + "unique_prs": 5204 + }, + { + "author": "codacy-bot", + "num_comments": 31784, + "unique_repos": 216, + "unique_prs": 1680 + }, + { + "author": "dieunb", + "num_comments": 6265, + "unique_repos": 131, + "unique_prs": 1388 + }, + { + "author": "stephentoub", + "num_comments": 5158, + "unique_repos": 9, + "unique_prs": 873 + }, + { + "author": "hound[bot]", + "num_comments": 5041, + "unique_repos": 46, + "unique_prs": 389 + }, + { + "author": "codeschool-kiddo", + "num_comments": 5005, + "unique_repos": 983, + "unique_prs": 4883 + }, + { + "author": "vaadin-bot", + "num_comments": 4760, + "unique_repos": 37, + "unique_prs": 831 + }, + { + "author": "github-actions[bot]", + "num_comments": 4721, + "unique_repos": 38, + "unique_prs": 227 + }, + { + "author": "timabbott", + "num_comments": 4704, + "unique_repos": 10, + "unique_prs": 1095 + } + ], + "meta": [ + { + "name": "author", + "type": "LowCardinality(String)" + }, + { + "name": "num_comments", + "type": "UInt64" + }, + { + "name": "unique_repos", + "type": "UInt64" + }, + { + "name": "unique_prs", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.081821617, + "rows_read": 3947090, + "bytes_read": 40658450 + }, + "executionTime": 0.189, + "requestId": "01KA4BCWXFMJFW9GE8Z8S58VWW", + "length": 813 + }, + "name": "pipe_46.pipe", + "question": { + "name": "pipe_46.pipe", + "content": "DESCRIPTION >\n Top 10 Authors with the most code reviews. Return the author, the number of pull request comments created, and from those, the number of unique repositories and PRs.\n\nNODE endpoint\nSQL >\n SELECT\n actor_login,\n count(),\n uniq(repo_name) AS repos,\n uniq(repo_name, number) AS prs\n FROM github_events\n WHERE (event_type = 'PullRequestReviewCommentEvent') AND (action = 'created')\n GROUP BY actor_login\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 Authors with the most code reviews. Return the author, the number of pull request comments created, and from those, the number of unique repositories and PRs." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.435, + "totalDuration": 7.503, + "tokens": { + "promptTokens": 4608, + "completionTokens": 934, + "totalTokens": 5542 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n actor_login AS author,\n count(*) AS num_comments,\n countDistinct(repo_name) AS unique_repos,\n countDistinct(tuple(repo_name, number)) AS unique_prs\nFROM github_events\nWHERE event_type = 'PullRequestReviewCommentEvent' AND action = 'created'\nGROUP BY actor_login\nORDER BY num_comments DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "author": "houndci-bot", + "num_comments": 62390, + "unique_repos": 530, + "unique_prs": 5115 + }, + { + "author": "houndci", + "num_comments": 54995, + "unique_repos": 639, + "unique_prs": 5204 + }, + { + "author": "codacy-bot", + "num_comments": 31784, + "unique_repos": 216, + "unique_prs": 1680 + }, + { + "author": "dieunb", + "num_comments": 6265, + "unique_repos": 131, + "unique_prs": 1388 + }, + { + "author": "stephentoub", + "num_comments": 5158, + "unique_repos": 9, + "unique_prs": 873 + }, + { + "author": "hound[bot]", + "num_comments": 5041, + "unique_repos": 46, + "unique_prs": 389 + }, + { + "author": "codeschool-kiddo", + "num_comments": 5005, + "unique_repos": 983, + "unique_prs": 4883 + }, + { + "author": "vaadin-bot", + "num_comments": 4760, + "unique_repos": 37, + "unique_prs": 831 + }, + { + "author": "github-actions[bot]", + "num_comments": 4721, + "unique_repos": 38, + "unique_prs": 227 + }, + { + "author": "timabbott", + "num_comments": 4704, + "unique_repos": 10, + "unique_prs": 1095 + } + ], + "meta": [ + { + "name": "author", + "type": "LowCardinality(String)" + }, + { + "name": "num_comments", + "type": "UInt64" + }, + { + "name": "unique_repos", + "type": "UInt64" + }, + { + "name": "unique_prs", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 0.081821617, + "rows_read": 3947090, + "bytes_read": 40658450 + }, + "executionTime": 0.189, + "requestId": "01KA4BCWXFMJFW9GE8Z8S58VWW", + "length": 813 + }, + "name": "pipe_46.pipe", + "question": { + "name": "pipe_46.pipe", + "content": "DESCRIPTION >\n Top 10 Authors with the most code reviews. Return the author, the number of pull request comments created, and from those, the number of unique repositories and PRs.\n\nNODE endpoint\nSQL >\n SELECT\n actor_login,\n count(),\n uniq(repo_name) AS repos,\n uniq(repo_name, number) AS prs\n FROM github_events\n WHERE (event_type = 'PullRequestReviewCommentEvent') AND (action = 'created')\n GROUP BY actor_login\n ORDER BY count() DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 Authors with the most code reviews. Return the author, the number of pull request comments created, and from those, the number of unique repositories and PRs." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.435, + "totalDuration": 7.503, + "tokens": { + "promptTokens": 4608, + "completionTokens": 934, + "totalTokens": 5542 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73bb04fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b4e73bb04fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e78b1214ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e7f9a7eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_47.pipe", + "question": { + "name": "pipe_47.pipe", + "content": "DESCRIPTION >\n Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\n\nNODE endpoint\nSQL >\n SELECT\n arrayJoin(labels) AS label,\n count() AS c\n FROM github_events\n WHERE (event_type IN ('IssuesEvent', 'PullRequestEvent', 'IssueCommentEvent')) AND (action IN ('created', 'opened', 'labeled'))\n GROUP BY label\n ORDER BY c DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e73bb04fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73bb04fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e78b1214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e73bb04fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_47.pipe", + "question": { + "name": "pipe_47.pipe", + "content": "DESCRIPTION >\n Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\n\nNODE endpoint\nSQL >\n SELECT\n arrayJoin(labels) AS label,\n count() AS c\n FROM github_events\n WHERE (event_type IN ('IssuesEvent', 'PullRequestEvent', 'IssueCommentEvent')) AND (action IN ('created', 'opened', 'labeled'))\n GROUP BY label\n ORDER BY c DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73bb04fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e78b1214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_47.pipe", + "question": { + "name": "pipe_47.pipe", + "content": "DESCRIPTION >\n Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\n\nNODE endpoint\nSQL >\n SELECT\n arrayJoin(labels) AS label,\n count() AS c\n FROM github_events\n WHERE (event_type IN ('IssuesEvent', 'PullRequestEvent', 'IssueCommentEvent')) AND (action IN ('created', 'opened', 'labeled'))\n GROUP BY label\n ORDER BY c DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e73bb04fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73bb04fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b4e73bb04fa9-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e78b1214ce-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e7f9a7eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_47.pipe", + "question": { + "name": "pipe_47.pipe", + "content": "DESCRIPTION >\n Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\n\nNODE endpoint\nSQL >\n SELECT\n arrayJoin(labels) AS label,\n count() AS c\n FROM github_events\n WHERE (event_type IN ('IssuesEvent', 'PullRequestEvent', 'IssueCommentEvent')) AND (action IN ('created', 'opened', 'labeled'))\n GROUP BY label\n ORDER BY c DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e73bb04fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 most popular labels for issues and pull requests. Return the label and the number of times it has been used in issues, pull requests, and issue comments created, opened, or labeled.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73bb04fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e78b1214ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT\n SUBSTRING_INDEX(repo_name, '/', 1) AS organization_name,\n uniqExact(actor_login) AS unique_authors,\n uniqExact(if(event_type='PullRequestEvent' AND action='opened', actor_login, NULL)) AS unique_pull_request_authors,\n uniqExact(if(event_type='IssuesEvent' AND action='opened', actor_login, NULL)) AS unique_issue_authors,\n uniqExact(if(event_type='IssueCommentEvent', actor_login, NULL)) AS unique_issue_comment_authors,\n uniqExact(if(event_type='PushEvent', actor_login, NULL)) AS unique_push_authors\nFROM github_events\nWHERE repo_name != ''\nGROUP BY organization_name\nHAVING organization_name != ''\nORDER BY unique_authors DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "organization_name": "tensorflow", + "unique_authors": 75254, + "unique_pull_request_authors": 938, + "unique_issue_authors": 7763, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "vuejs", + "unique_authors": 70367, + "unique_pull_request_authors": 1092, + "unique_issue_authors": 0, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "sindresorhus", + "unique_authors": 60380, + "unique_pull_request_authors": 1391, + "unique_issue_authors": 1986, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "apache", + "unique_authors": 54806, + "unique_pull_request_authors": 71, + "unique_issue_authors": 2, + "unique_issue_comment_authors": 0, + "unique_push_authors": 772 + }, + { + "organization_name": "shadowsocks", + "unique_authors": 33825, + "unique_pull_request_authors": 155, + "unique_issue_authors": 678, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "square", + "unique_authors": 31590, + "unique_pull_request_authors": 581, + "unique_issue_authors": 1151, + "unique_issue_comment_authors": 84, + "unique_push_authors": 0 + }, + { + "organization_name": "yarnpkg", + "unique_authors": 30859, + "unique_pull_request_authors": 312, + "unique_issue_authors": 0, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "yahoo", + "unique_authors": 29598, + "unique_pull_request_authors": 427, + "unique_issue_authors": 27, + "unique_issue_comment_authors": 24, + "unique_push_authors": 0 + }, + { + "organization_name": "alibaba", + "unique_authors": 29445, + "unique_pull_request_authors": 0, + "unique_issue_authors": 0, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "reactjs", + "unique_authors": 27973, + "unique_pull_request_authors": 810, + "unique_issue_authors": 519, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + } + ], + "meta": [ + { + "name": "organization_name", + "type": "LowCardinality(String)" + }, + { + "name": "unique_authors", + "type": "UInt64" + }, + { + "name": "unique_pull_request_authors", + "type": "UInt64" + }, + { + "name": "unique_issue_authors", + "type": "UInt64" + }, + { + "name": "unique_issue_comment_authors", + "type": "UInt64" + }, + { + "name": "unique_push_authors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 2.911329454, + "rows_read": 200000000, + "bytes_read": 2408365128 + }, + "executionTime": 3.206, + "requestId": "01KA4BDDMP03K4DSN528RMDXD7", + "length": 1734 + }, + "name": "pipe_48.pipe", + "question": { + "name": "pipe_48.pipe", + "content": "DESCRIPTION >\n top 10 Organizations by the size of community (get the organization name from the repo_name)\n return the organization name, the number of unique authors, the number of unique pull request authors, the number of unique issue authors, the number of unique issue comment authors, and the number of unique push authors.\n\nNODE endpoint\nSQL >\n SELECT\n lower(substring(repo_name, 1, position(repo_name, '/'))) AS org,\n uniq(actor_login) AS authors,\n uniqIf(actor_login, event_type = 'PullRequestEvent') AS pr_authors,\n uniqIf(actor_login, event_type = 'IssuesEvent') AS issue_authors,\n uniqIf(actor_login, event_type = 'IssueCommentEvent') AS comment_authors,\n uniqIf(actor_login, event_type = 'PullRequestReviewCommentEvent') AS review_authors,\n uniqIf(actor_login, event_type = 'PushEvent') AS push_authors\n FROM github_events\n WHERE event_type IN ('PullRequestEvent', 'IssuesEvent', 'IssueCommentEvent', 'PullRequestReviewCommentEvent', 'PushEvent')\n GROUP BY org\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Organizations by the size of community (get the organization name from the repo_name)\n return the organization name, the number of unique authors, the number of unique pull request authors, the number of unique issue authors, the number of unique issue comment authors, and the number of unique push authors." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.328, + "totalDuration": 24.438, + "tokens": { + "promptTokens": 4635, + "completionTokens": 2649, + "totalTokens": 7284 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT\n SUBSTRING_INDEX(repo_name, '/', 1) AS organization_name,\n uniqExact(actor_login) AS unique_authors,\n uniqExact(if(event_type='PullRequestEvent' AND action='opened', actor_login, NULL)) AS unique_pull_request_authors,\n uniqExact(if(event_type='IssuesEvent' AND action='opened', actor_login, NULL)) AS unique_issue_authors,\n uniqExact(if(event_type='IssueCommentEvent', actor_login, NULL)) AS unique_issue_comment_authors,\n uniqExact(if(event_type='PushEvent', actor_login, NULL)) AS unique_push_authors\nFROM github_events\nWHERE repo_name != ''\nGROUP BY organization_name\nHAVING organization_name != ''\nORDER BY unique_authors DESC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "organization_name": "tensorflow", + "unique_authors": 75254, + "unique_pull_request_authors": 938, + "unique_issue_authors": 7763, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "vuejs", + "unique_authors": 70367, + "unique_pull_request_authors": 1092, + "unique_issue_authors": 0, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "sindresorhus", + "unique_authors": 60380, + "unique_pull_request_authors": 1391, + "unique_issue_authors": 1986, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "apache", + "unique_authors": 54806, + "unique_pull_request_authors": 71, + "unique_issue_authors": 2, + "unique_issue_comment_authors": 0, + "unique_push_authors": 772 + }, + { + "organization_name": "shadowsocks", + "unique_authors": 33825, + "unique_pull_request_authors": 155, + "unique_issue_authors": 678, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "square", + "unique_authors": 31590, + "unique_pull_request_authors": 581, + "unique_issue_authors": 1151, + "unique_issue_comment_authors": 84, + "unique_push_authors": 0 + }, + { + "organization_name": "yarnpkg", + "unique_authors": 30859, + "unique_pull_request_authors": 312, + "unique_issue_authors": 0, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "yahoo", + "unique_authors": 29598, + "unique_pull_request_authors": 427, + "unique_issue_authors": 27, + "unique_issue_comment_authors": 24, + "unique_push_authors": 0 + }, + { + "organization_name": "alibaba", + "unique_authors": 29445, + "unique_pull_request_authors": 0, + "unique_issue_authors": 0, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + }, + { + "organization_name": "reactjs", + "unique_authors": 27973, + "unique_pull_request_authors": 810, + "unique_issue_authors": 519, + "unique_issue_comment_authors": 0, + "unique_push_authors": 0 + } + ], + "meta": [ + { + "name": "organization_name", + "type": "LowCardinality(String)" + }, + { + "name": "unique_authors", + "type": "UInt64" + }, + { + "name": "unique_pull_request_authors", + "type": "UInt64" + }, + { + "name": "unique_issue_authors", + "type": "UInt64" + }, + { + "name": "unique_issue_comment_authors", + "type": "UInt64" + }, + { + "name": "unique_push_authors", + "type": "UInt64" + } + ], + "statistics": { + "elapsed": 2.911329454, + "rows_read": 200000000, + "bytes_read": 2408365128 + }, + "executionTime": 3.206, + "requestId": "01KA4BDDMP03K4DSN528RMDXD7", + "length": 1734 + }, + "name": "pipe_48.pipe", + "question": { + "name": "pipe_48.pipe", + "content": "DESCRIPTION >\n top 10 Organizations by the size of community (get the organization name from the repo_name)\n return the organization name, the number of unique authors, the number of unique pull request authors, the number of unique issue authors, the number of unique issue comment authors, and the number of unique push authors.\n\nNODE endpoint\nSQL >\n SELECT\n lower(substring(repo_name, 1, position(repo_name, '/'))) AS org,\n uniq(actor_login) AS authors,\n uniqIf(actor_login, event_type = 'PullRequestEvent') AS pr_authors,\n uniqIf(actor_login, event_type = 'IssuesEvent') AS issue_authors,\n uniqIf(actor_login, event_type = 'IssueCommentEvent') AS comment_authors,\n uniqIf(actor_login, event_type = 'PullRequestReviewCommentEvent') AS review_authors,\n uniqIf(actor_login, event_type = 'PushEvent') AS push_authors\n FROM github_events\n WHERE event_type IN ('PullRequestEvent', 'IssuesEvent', 'IssueCommentEvent', 'PullRequestReviewCommentEvent', 'PushEvent')\n GROUP BY org\n ORDER BY authors DESC\n LIMIT 10\n\nTYPE endpoint", + "question": "top 10 Organizations by the size of community (get the organization name from the repo_name)\n return the organization name, the number of unique authors, the number of unique pull request authors, the number of unique issue authors, the number of unique issue comment authors, and the number of unique push authors." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.328, + "totalDuration": 24.438, + "tokens": { + "promptTokens": 4635, + "completionTokens": 2649, + "totalTokens": 7284 + } + }, + "error": null + } + ] + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73f73eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b4e73f73eb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e7dd844fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e81c6414ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_49.pipe", + "question": { + "name": "pipe_49.pipe", + "content": "DESCRIPTION >\n Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\n\nNODE endpoint\nSQL >\n SELECT repo_name, length(repo_name) as name_length FROM github_events WHERE event_type = 'WatchEvent' GROUP BY repo_name ORDER BY name_length DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e73f73eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73f73eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e7dd844fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "attempts": [ + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e73f73eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_49.pipe", + "question": { + "name": "pipe_49.pipe", + "content": "DESCRIPTION >\n Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\n\nNODE endpoint\nSQL >\n SELECT repo_name, length(repo_name) as name_length FROM github_events WHERE event_type = 'WatchEvent' GROUP BY repo_name ORDER BY name_length DESC LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73f73eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e7dd844fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_49.pipe", + "question": { + "name": "pipe_49.pipe", + "content": "DESCRIPTION >\n Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\n\nNODE endpoint\nSQL >\n SELECT repo_name, length(repo_name) as name_length FROM github_events WHERE event_type = 'WatchEvent' GROUP BY repo_name ORDER BY name_length DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e73f73eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + }, + { + "sql": null, + "sqlResult": null, + "metrics": null, + "error": "Error from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"I previously asked: \\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73f73eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"I previously asked: \\\\\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\\\\\"\\\\n\\\\nYou generated this SQL query:\\\\n```sql\\\\nnull\\\\n```\\\\n\\\\nBut it resulted in this error:\\\\n```\\\\nError from model: {\\\\\\\"name\\\\\\\":\\\\\\\"AI_APICallError\\\\\\\",\\\\\\\"url\\\\\\\":\\\\\\\"https://openrouter.ai/api/v1/chat/completions\\\\\\\",\\\\\\\"requestBodyValues\\\\\\\":{\\\\\\\"model\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha\\\\\\\",\\\\\\\"temperature\\\\\\\":0,\\\\\\\"messages\\\\\\\":[{\\\\\\\"role\\\\\\\":\\\\\\\"system\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"\\\\\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\\\\\n- Only write one single SQL query, do not return multiple queries.\\\\\\\\n- You will be given a list of datasources (tables) available to you.\\\\\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\\\\\n\\\\\\\\n \\\\\\\\n These are the datasources (tables) available to you:\\\\\\\\n github_events: \\\\\\\\n DESCRIPTION > \\\\\\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\\\\\n\\\\\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\\\\\n When filtering PRs or issues use action = 'opened'\\\\\\\\n\\\\\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\\\\\n\\\\\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\\\\\n\\\\\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\\\\\n\\\\\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\\\\\n\\\\\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\\\\\n\\\\\\\\nSCHEMA >\\\\\\\\n file_time DateTime `json:$.file_time`,\\\\\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\\\\\n created_at DateTime `json:$.created_at`,\\\\\\\\n updated_at DateTime `json:$.updated_at`,\\\\\\\\n action LowCardinality(String) `json:$.action`,\\\\\\\\n comment_id UInt64 `json:$.comment_id`,\\\\\\\\n body Nullable(String) `json:$.body`,\\\\\\\\n path Nullable(String) `json:$.path`,\\\\\\\\n position Int32 `json:$.position`,\\\\\\\\n line Int32 `json:$.line`,\\\\\\\\n ref Nullable(String) `json:$.ref`,\\\\\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\\\\\n number Int32 `json:$.number`,\\\\\\\\n title Nullable(String) `json:$.title`,\\\\\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\\\\\n state LowCardinality(String) `json:$.state`,\\\\\\\\n locked UInt8 `json:$.locked`,\\\\\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\\\\\n comments UInt32 `json:$.comments`,\\\\\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\\\\\n closed_at DateTime `json:$.closed_at`,\\\\\\\\n merged_at DateTime `json:$.merged_at`,\\\\\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\\\\\n head_sha String `json:$.head_sha`,\\\\\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\\\\\n base_sha String `json:$.base_sha`,\\\\\\\\n merged UInt8 `json:$.merged`,\\\\\\\\n mergeable UInt8 `json:$.mergeable`,\\\\\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\\\\\n review_comments UInt32 `json:$.review_comments`,\\\\\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\\\\\n commits UInt32 `json:$.commits`,\\\\\\\\n additions UInt32 `json:$.additions`,\\\\\\\\n deletions UInt32 `json:$.deletions`,\\\\\\\\n changed_files UInt32 `json:$.changed_files`,\\\\\\\\n diff_hunk String `json:$.diff_hunk`,\\\\\\\\n original_position UInt32 `json:$.original_position`,\\\\\\\\n commit_id String `json:$.commit_id`,\\\\\\\\n original_commit_id String `json:$.original_commit_id`,\\\\\\\\n push_size UInt32 `json:$.push_size`,\\\\\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\\\\\n release_tag_name String `json:$.release_tag_name`,\\\\\\\\n release_name String `json:$.release_name`,\\\\\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_PARTITION_KEY \\\\\\\\\\\\\\\"toYear(created_at)\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"event_type, repo_name, created_at\\\\\\\\\\\\\\\"\\\\\\\\n\\\\\\\\n\\\\\\\\nresults: \\\\\\\\n SCHEMA >\\\\\\\\n `sql` String `json:$.sql`,\\\\\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\\\\\n `name` String `json:$.name`,\\\\\\\\n `question` String `json:$.question.question`,\\\\\\\\n `model` String `json:$.model`,\\\\\\\\n `provider` String `json:$.provider`,\\\\\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\\\\\n\\\\\\\\nENGINE \\\\\\\\\\\\\\\"MergeTree\\\\\\\\\\\\\\\"\\\\\\\\nENGINE_SORTING_KEY \\\\\\\\\\\\\\\"model, provider, name\\\\\\\\\\\\\\\" \\\\\\\\n \\\\\\\\n\\\\\\\\n \\\\\\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\\\\\n WITH my_cte AS (\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n )\\\\\\\\n SELECT * FROM my_cte\\\\\\\\n \\\\\\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\\\\\n SELECT * FROM my_node_1\\\\\\\\n \\\\\\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\\\\\\\\\"%\\\\\\\\\\\\\\\" character at the beginning of the query.\\\\\\\\n \\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n \\\\\\\\n %\\\\\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\\\\\\\\\"default_value\\\\\\\\\\\\\\\")}}}}\\\\\\\\n \\\\\\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\\\\\n \\\\\\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\\\\\n \\\\\\\\n \\\\\\\\n {{%if not defined(start_date)%}}\\\\\\\\n timestamp BETWEEN now() - interval 30 day\\\\\\\\n {{%else%}}\\\\\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\\\\\n {{%end%}}\\\\\\\\n {{%if not defined(end_date)%}}\\\\\\\\n AND now()\\\\\\\\n {{%else%}}\\\\\\\\n AND {{{{DateTime(end_date)}}}} \\\\\\\\n {{%end%}}\\\\\\\\n \\\\\\\\n - Parameters must not be quoted.\\\\\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\\\\\n {{% if defined('my_param') %}}\\\\\\\\n {{% if defined(my_param) %}}\\\\\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\\\\\n - Do not reference the current node name in the SQL.\\\\\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\\\\\n - Use ONLY SELECT statements in the SQL section.\\\\\\\\n - INSERT INTO is not supported in SQL section.\\\\\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\\\\\n - When aliasing a column, use first the column name and then the alias.\\\\\\\\n - General functions and aggregate functions are case sensitive.\\\\\\\\n - Character insensitive functions are case insensitive.\\\\\\\\n - Parameters are never quoted in any case.\\\\\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\\\\\n \\\\\\\\n SELECT\\\\\\\\n date,\\\\\\\\n avgMerge(avg_duration_state) avg_time,\\\\\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\\\\\n FROM tinybird.pipe_stats\\\\\\\\n where pipe_id = 'PIPE_ID'\\\\\\\\n group by date\\\\\\\\n \\\\\\\\n\\\\\\\\n\\\\\\\"},{\\\\\\\"role\\\\\\\":\\\\\\\"user\\\\\\\",\\\\\\\"content\\\\\\\":\\\\\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\\\\\"}],\\\\\\\"stream\\\\\\\":true},\\\\\\\"statusCode\\\\\\\":400,\\\\\\\"responseHeaders\\\\\\\":{\\\\\\\"access-control-allow-origin\\\\\\\":\\\\\\\"*\\\\\\\",\\\\\\\"cf-ray\\\\\\\":\\\\\\\"99f0b4e73f73eb58-ORD\\\\\\\",\\\\\\\"connection\\\\\\\":\\\\\\\"keep-alive\\\\\\\",\\\\\\\"content-type\\\\\\\":\\\\\\\"application/json\\\\\\\",\\\\\\\"date\\\\\\\":\\\\\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\\\\\",\\\\\\\"permissions-policy\\\\\\\":\\\\\\\"payment=(self \\\\\\\\\\\\\\\"https://checkout.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://connect-js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://*.js.stripe.com\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\"https://hooks.stripe.com\\\\\\\\\\\\\\\")\\\\\\\",\\\\\\\"referrer-policy\\\\\\\":\\\\\\\"no-referrer, strict-origin-when-cross-origin\\\\\\\",\\\\\\\"server\\\\\\\":\\\\\\\"cloudflare\\\\\\\",\\\\\\\"transfer-encoding\\\\\\\":\\\\\\\"chunked\\\\\\\",\\\\\\\"vary\\\\\\\":\\\\\\\"Accept-Encoding\\\\\\\",\\\\\\\"x-content-type-options\\\\\\\":\\\\\\\"nosniff\\\\\\\"},\\\\\\\"responseBody\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"error\\\\\\\\\\\\\\\":{\\\\\\\\\\\\\\\"message\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\\\\\\\\\",\\\\\\\\\\\\\\\"code\\\\\\\\\\\\\\\":400},\\\\\\\\\\\\\\\"user_id\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"isRetryable\\\\\\\":false}\\\\n```\\\\n\\\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e7dd844fa9-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e81c6414ce-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:40 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}", + "name": "pipe_49.pipe", + "question": { + "name": "pipe_49.pipe", + "content": "DESCRIPTION >\n Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\n\nNODE endpoint\nSQL >\n SELECT repo_name, length(repo_name) as name_length FROM github_events WHERE event_type = 'WatchEvent' GROUP BY repo_name ORDER BY name_length DESC LIMIT 10\n\nTYPE endpoint", + "question": "I previously asked: \"I previously asked: \"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e73f73eb58-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"\n\nYou generated this SQL query:\n```sql\nnull\n```\n\nBut it resulted in this error:\n```\nError from model: {\"name\":\"AI_APICallError\",\"url\":\"https://openrouter.ai/api/v1/chat/completions\",\"requestBodyValues\":{\"model\":\"openrouter/sherlock-think-alpha\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\n- Only write one single SQL query, do not return multiple queries.\\n- You will be given a list of datasources (tables) available to you.\\n- You will be given a list of functions that you can use in the SQL query.\\n- You will be given a list of instructions on how to generate the SQL query.\\n- You don't have access to the data in the database, so don't return fake responses.\\n\\n \\n These are the datasources (tables) available to you:\\n github_events: \\n DESCRIPTION > \\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\n\\n The WatchEvent is the event when someone gives a star to a repo.\\n When filtering PRs or issues use action = 'opened'\\n\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\n\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\n\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\n\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\n\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\n\\nSCHEMA >\\n file_time DateTime `json:$.file_time`,\\n event_type LowCardinality(String) `json:$.event_type`,\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\n created_at DateTime `json:$.created_at`,\\n updated_at DateTime `json:$.updated_at`,\\n action LowCardinality(String) `json:$.action`,\\n comment_id UInt64 `json:$.comment_id`,\\n body Nullable(String) `json:$.body`,\\n path Nullable(String) `json:$.path`,\\n position Int32 `json:$.position`,\\n line Int32 `json:$.line`,\\n ref Nullable(String) `json:$.ref`,\\n ref_type LowCardinality(String) `json:$.ref_type`,\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\n number Int32 `json:$.number`,\\n title Nullable(String) `json:$.title`,\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\n state LowCardinality(String) `json:$.state`,\\n locked UInt8 `json:$.locked`,\\n assignee LowCardinality(String) `json:$.assignee`,\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\n comments UInt32 `json:$.comments`,\\n author_association LowCardinality(String) `json:$.author_association`,\\n closed_at DateTime `json:$.closed_at`,\\n merged_at DateTime `json:$.merged_at`,\\n merge_commit_sha String `json:$.merge_commit_sha`,\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\n head_ref LowCardinality(String) `json:$.head_ref`,\\n head_sha String `json:$.head_sha`,\\n base_ref LowCardinality(String) `json:$.base_ref`,\\n base_sha String `json:$.base_sha`,\\n merged UInt8 `json:$.merged`,\\n mergeable UInt8 `json:$.mergeable`,\\n rebaseable UInt8 `json:$.rebaseable`,\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\n merged_by LowCardinality(String) `json:$.merged_by`,\\n review_comments UInt32 `json:$.review_comments`,\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\n commits UInt32 `json:$.commits`,\\n additions UInt32 `json:$.additions`,\\n deletions UInt32 `json:$.deletions`,\\n changed_files UInt32 `json:$.changed_files`,\\n diff_hunk String `json:$.diff_hunk`,\\n original_position UInt32 `json:$.original_position`,\\n commit_id String `json:$.commit_id`,\\n original_commit_id String `json:$.original_commit_id`,\\n push_size UInt32 `json:$.push_size`,\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\n member_login LowCardinality(String) `json:$.member_login`,\\n release_tag_name String `json:$.release_tag_name`,\\n release_name String `json:$.release_name`,\\n review_state LowCardinality(String) `json:$.review_state`\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_PARTITION_KEY \\\"toYear(created_at)\\\"\\nENGINE_SORTING_KEY \\\"event_type, repo_name, created_at\\\"\\n\\n\\nresults: \\n SCHEMA >\\n `sql` String `json:$.sql`,\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\n `name` String `json:$.name`,\\n `question` String `json:$.question.question`,\\n `model` String `json:$.model`,\\n `provider` String `json:$.provider`,\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\n `llm_error` String `json:$.error` DEFAULT '',\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\n\\nENGINE \\\"MergeTree\\\"\\nENGINE_SORTING_KEY \\\"model, provider, name\\\" \\n \\n\\n \\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\n # This is wrong. Create a node instead of the cte first and then reuse it\\n WITH my_cte AS (\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n )\\n SELECT * FROM my_cte\\n \\n - Reusing a node means to query that node as a table in the query. Example:\\n # This is correct. Create a node instead of the cte first and then reuse it\\n SELECT * FROM my_node_1\\n \\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\n - In case the user asks for dynamic parameters, the query must start with \\\"%\\\" character and a newline on top of every query to be able to use the parameters.\\n - If the query does not need dynamic parameters, omit the \\\"%\\\" character at the beginning of the query.\\n \\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n \\n %\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\"default_value\\\")}}}}\\n \\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\n - Use ALWAYS hardcoded values for default values for parameters.\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\n \\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\n \\n \\n {{%if not defined(start_date)%}}\\n timestamp BETWEEN now() - interval 30 day\\n {{%else%}}\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\n {{%end%}}\\n {{%if not defined(end_date)%}}\\n AND now()\\n {{%else%}}\\n AND {{{{DateTime(end_date)}}}} \\n {{%end%}}\\n \\n - Parameters must not be quoted.\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\n {{% if defined('my_param') %}}\\n {{% if defined(my_param) %}}\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\n - Use node names as table names only when nodes are present in the same exploration.\\n - Do not reference the current node name in the SQL.\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\n - Use ONLY SELECT statements in the SQL section.\\n - INSERT INTO is not supported in SQL section.\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\n - When aliasing a column, use first the column name and then the alias.\\n - General functions and aggregate functions are case sensitive.\\n - Character insensitive functions are case insensitive.\\n - Parameters are never quoted in any case.\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\n \\n SELECT\\n date,\\n avgMerge(avg_duration_state) avg_time,\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\n FROM tinybird.pipe_stats\\n where pipe_id = 'PIPE_ID'\\n group by date\\n \\n\\n\"},{\"role\":\"user\",\"content\":\"I previously asked: \\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"\\n\\nYou generated this SQL query:\\n```sql\\nnull\\n```\\n\\nBut it resulted in this error:\\n```\\nError from model: {\\\"name\\\":\\\"AI_APICallError\\\",\\\"url\\\":\\\"https://openrouter.ai/api/v1/chat/completions\\\",\\\"requestBodyValues\\\":{\\\"model\\\":\\\"openrouter/sherlock-think-alpha\\\",\\\"temperature\\\":0,\\\"messages\\\":[{\\\"role\\\":\\\"system\\\",\\\"content\\\":\\\"\\\\n- You will be asked to generate a SQL query to answer a question about the data in the database.\\\\n- If you don't know the answer, do your best effort to provide some code that can be used to generate the SQL query.\\\\n- You should ONLY return the plain SQL query, nothing else. IMPORTANT: DO NOT NEVER UNDER ANY CIRCUMSTANCES RETURN A MARKDOWN-LIKE CODE BLOCK, CONTEXT OR INSTRUCTIONS, ONLY WRITE SQL AND NOTHING ELSE.\\\\n- The dataset is huge, so ADD LIMITS TO THE QUERY FOR PAGINATION. If not told otherwise, add LIMIT 10 to the query.\\\\n- Only write one single SQL query, do not return multiple queries.\\\\n- You will be given a list of datasources (tables) available to you.\\\\n- You will be given a list of functions that you can use in the SQL query.\\\\n- You will be given a list of instructions on how to generate the SQL query.\\\\n- You don't have access to the data in the database, so don't return fake responses.\\\\n\\\\n \\\\n These are the datasources (tables) available to you:\\\\n github_events: \\\\n DESCRIPTION > \\\\n event_type Enum('CommitCommentEvent' = 1, 'CreateEvent' = 2, 'DeleteEvent' = 3, 'ForkEvent' = 4,'GollumEvent' = 5, 'IssueCommentEvent' = 6, 'IssuesEvent' = 7, 'MemberEvent' = 8, 'PublicEvent' = 9, 'PullRequestEvent' = 10, 'PullRequestReviewCommentEvent' = 11, 'PushEvent' = 12, 'ReleaseEvent' = 13, 'SponsorshipEvent' = 14, 'WatchEvent' = 15, 'GistEvent' = 16, 'FollowEvent' = 17, 'DownloadEvent' = 18, 'PullRequestReviewEvent' = 19, 'ForkApplyEvent' = 20, 'Event' = 21, 'TeamAddEvent' = 22)\\\\n\\\\n The WatchEvent is the event when someone gives a star to a repo.\\\\n When filtering PRs or issues use action = 'opened'\\\\n\\\\n action Enum('none' = 0, 'created' = 1, 'added' = 2, 'edited' = 3, 'deleted' = 4, 'opened' = 5, 'closed' = 6, 'reopened' = 7, 'assigned' = 8, 'unassigned' = 9, 'labeled' = 10, 'unlabeled' = 11, 'review_requested' = 12, 'review_request_removed' = 13, 'synchronize' = 14, 'started' = 15, 'published' = 16, 'update' = 17, 'create' = 18, 'fork' = 19, 'merged' = 20)\\\\n\\\\n ref_type Enum('none' = 0, 'branch' = 1, 'tag' = 2, 'repository' = 3, 'unknown' = 4)\\\\n\\\\n author_association Enum('NONE' = 0, 'CONTRIBUTOR' = 1, 'OWNER' = 2, 'COLLABORATOR' = 3, 'MEMBER' = 4, 'MANNEQUIN' = 5)\\\\n\\\\n mergeable_state Enum('unknown' = 0, 'dirty' = 1, 'clean' = 2, 'unstable' = 3, 'draft' = 4, 'blocked' = 5)\\\\n\\\\n review_state Enum('none' = 0, 'approved' = 1, 'changes_requested' = 2, 'commented' = 3, 'dismissed' = 4, 'pending' = 5)\\\\n\\\\nSCHEMA >\\\\n file_time DateTime `json:$.file_time`,\\\\n event_type LowCardinality(String) `json:$.event_type`,\\\\n actor_login LowCardinality(String) `json:$.actor_login` DEFAULT '',\\\\n repo_name LowCardinality(String) `json:$.repo_name` DEFAULT '',\\\\n created_at DateTime `json:$.created_at`,\\\\n updated_at DateTime `json:$.updated_at`,\\\\n action LowCardinality(String) `json:$.action`,\\\\n comment_id UInt64 `json:$.comment_id`,\\\\n body Nullable(String) `json:$.body`,\\\\n path Nullable(String) `json:$.path`,\\\\n position Int32 `json:$.position`,\\\\n line Int32 `json:$.line`,\\\\n ref Nullable(String) `json:$.ref`,\\\\n ref_type LowCardinality(String) `json:$.ref_type`,\\\\n creator_user_login Nullable(String) `json:$.creator_user_login`,\\\\n number Int32 `json:$.number`,\\\\n title Nullable(String) `json:$.title`,\\\\n labels Array(LowCardinality(String)) `json:$.labels[:]`,\\\\n state LowCardinality(String) `json:$.state`,\\\\n locked UInt8 `json:$.locked`,\\\\n assignee LowCardinality(String) `json:$.assignee`,\\\\n assignees Array(LowCardinality(String)) `json:$.assignees[:]`,\\\\n comments UInt32 `json:$.comments`,\\\\n author_association LowCardinality(String) `json:$.author_association`,\\\\n closed_at DateTime `json:$.closed_at`,\\\\n merged_at DateTime `json:$.merged_at`,\\\\n merge_commit_sha String `json:$.merge_commit_sha`,\\\\n requested_reviewers Array(LowCardinality(String)) `json:$.requested_reviewers[:]`,\\\\n requested_teams Array(LowCardinality(String)) `json:$.requested_teams[:]`,\\\\n head_ref LowCardinality(String) `json:$.head_ref`,\\\\n head_sha String `json:$.head_sha`,\\\\n base_ref LowCardinality(String) `json:$.base_ref`,\\\\n base_sha String `json:$.base_sha`,\\\\n merged UInt8 `json:$.merged`,\\\\n mergeable UInt8 `json:$.mergeable`,\\\\n rebaseable UInt8 `json:$.rebaseable`,\\\\n mergeable_state LowCardinality(String) `json:$.mergeable_state`,\\\\n merged_by LowCardinality(String) `json:$.merged_by`,\\\\n review_comments UInt32 `json:$.review_comments`,\\\\n maintainer_can_modify UInt8 `json:$.maintainer_can_modify`,\\\\n commits UInt32 `json:$.commits`,\\\\n additions UInt32 `json:$.additions`,\\\\n deletions UInt32 `json:$.deletions`,\\\\n changed_files UInt32 `json:$.changed_files`,\\\\n diff_hunk String `json:$.diff_hunk`,\\\\n original_position UInt32 `json:$.original_position`,\\\\n commit_id String `json:$.commit_id`,\\\\n original_commit_id String `json:$.original_commit_id`,\\\\n push_size UInt32 `json:$.push_size`,\\\\n push_distinct_size UInt32 `json:$.push_distinct_size`,\\\\n member_login LowCardinality(String) `json:$.member_login`,\\\\n release_tag_name String `json:$.release_tag_name`,\\\\n release_name String `json:$.release_name`,\\\\n review_state LowCardinality(String) `json:$.review_state`\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_PARTITION_KEY \\\\\\\"toYear(created_at)\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"event_type, repo_name, created_at\\\\\\\"\\\\n\\\\n\\\\nresults: \\\\n SCHEMA >\\\\n `sql` String `json:$.sql`,\\\\n `sql_result_success` Bool `json:$.sqlResult.success`,\\\\n `sql_result_data` Array(String) `json:$.sqlResult.data[:]` DEFAULT [],\\\\n `sql_result_execution_time` Float32 `json:$.sqlResult.executionTime`,\\\\n `sql_result_error` String `json:$.sqlResult.error` DEFAULT '',\\\\n `sql_result_query_latency` Nullable(Float32) `json:$.sqlResult.statistics.elapsed`,\\\\n `sql_result_rows_read` Nullable(UInt64) `json:$.sqlResult.statistics.rows_read`,\\\\n `sql_result_bytes_read` Nullable(UInt64) `json:$.sqlResult.statistics.bytes_read`,\\\\n `name` String `json:$.name`,\\\\n `question` String `json:$.question.question`,\\\\n `model` String `json:$.model`,\\\\n `provider` String `json:$.provider`,\\\\n `llm_time_to_first_token` Float32 `json:$.metrics.timeToFirstToken`,\\\\n `llm_total_duration` Float32 `json:$.metrics.totalDuration`,\\\\n `llm_prompt_tokens` UInt32 `json:$.metrics.tokens.promptTokens`,\\\\n `llm_completion_tokens` UInt32 `json:$.metrics.tokens.completionTokens`,\\\\n `llm_total_tokens` UInt32 `json:$.metrics.tokens.totalTokens`,\\\\n `llm_error` String `json:$.error` DEFAULT '',\\\\n `attempts` Array(String) `json:$.attempts[:]` DEFAULT [],\\\\n\\\\nENGINE \\\\\\\"MergeTree\\\\\\\"\\\\nENGINE_SORTING_KEY \\\\\\\"model, provider, name\\\\\\\" \\\\n \\\\n\\\\n \\\\n - The SQL query must be a valid ClickHouse SQL query that mixes ClickHouse syntax and Tinybird templating syntax (Tornado templating language under the hood).\\\\n - DO NOT use CTEs, subqueries or common table expressions, WITH clauses, etc.\\\\n - Create multiple nodes to reuse the same query logic instead of using CTEs. Example:\\\\n # This is wrong. Create a node instead of the cte first and then reuse it\\\\n WITH my_cte AS (\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n )\\\\n SELECT * FROM my_cte\\\\n \\\\n - Reusing a node means to query that node as a table in the query. Example:\\\\n # This is correct. Create a node instead of the cte first and then reuse it\\\\n SELECT * FROM my_node_1\\\\n \\\\n - Use only dynamic parameters when the actual query needs them and the user asks for it.\\\\n - In case the user asks for dynamic parameters, the query must start with \\\\\\\"%\\\\\\\" character and a newline on top of every query to be able to use the parameters.\\\\n - If the query does not need dynamic parameters, omit the \\\\\\\"%\\\\\\\" character at the beginning of the query.\\\\n \\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n \\\\n %\\\\n SELECT * FROM events WHERE session_id={{{{String(my_param, \\\\\\\"default_value\\\\\\\")}}}}\\\\n \\\\n - The Parameter functions like this one {{{{String(my_param_name,default_value)}}}} can be one of the following: String, DateTime, Date, Float32, Float64, Int, Integer, UInt8, UInt16, UInt32, UInt64, UInt128, UInt256, Int8, Int16, Int32, Int64, Int128, Int256\\\\n - Parameter names must be different from column names. Pass always the param name and a default value to the function.\\\\n - Use ALWAYS hardcoded values for default values for parameters.\\\\n - Code inside the template {{{{template_expression}}}} follows the rules of Tornado templating language so no module is allowed to be imported. So for example you can't use now() as default value for a DateTime parameter. You need an if else block like this:\\\\n \\\\n AND timestamp BETWEEN {{DateTime(start_date, now() - interval 30 day)}} AND {{DateTime(end_date, now())}}\\\\n \\\\n \\\\n {{%if not defined(start_date)%}}\\\\n timestamp BETWEEN now() - interval 30 day\\\\n {{%else%}}\\\\n timestamp BETWEEN {{{{DateTime(start_date)}}}}\\\\n {{%end%}}\\\\n {{%if not defined(end_date)%}}\\\\n AND now()\\\\n {{%else%}}\\\\n AND {{{{DateTime(end_date)}}}} \\\\n {{%end%}}\\\\n \\\\n - Parameters must not be quoted.\\\\n - When you use defined function with a paremeter inside, do NOT add quotes around the parameter:\\\\n {{% if defined('my_param') %}}\\\\n {{% if defined(my_param) %}}\\\\n - Use datasource, service datasource, materialized view or node names as table names when doing SELECT statements.\\\\n - Use node names as table names only when nodes are present in the same exploration.\\\\n - Do not reference the current node name in the SQL.\\\\n - SQL queries only accept SELECT statements with conditions, aggregations, joins, etc.\\\\n - Do NOT use CREATE TABLE, INSERT INTO, CREATE DATABASE, etc.\\\\n - Use ONLY SELECT statements in the SQL section.\\\\n - INSERT INTO is not supported in SQL section.\\\\n - General functions supported are: BLAKE3,CAST,CHARACTER_LENGTH,CHAR_LENGTH,CRC32,CRC32IEEE,CRC64,DATE,DATE_DIFF,DATE_FORMAT,DATE_TRUNC,DAY,DAYOFMONTH,DAYOFWEEK,DAYOFYEAR,FORMAT_BYTES,FQDN,FROM_BASE64,FROM_DAYS,FROM_UNIXTIME,HOUR,INET6_ATON,INET6_NTOA,INET_ATON,INET_NTOA,IPv4CIDRToRange,IPv4NumToString,IPv4NumToStringClassC,IPv4StringToNum,IPv4StringToNumOrDefault,IPv4StringToNumOrNull,IPv4ToIPv6,IPv6CIDRToRange,IPv6NumToString,IPv6StringToNum,IPv6StringToNumOrDefault,IPv6StringToNumOrNull,JSONArrayLength,JSONExtract,JSONExtractArrayRaw,JSONExtractBool,JSONExtractFloat,JSONExtractInt,JSONExtractKeys,JSONExtractKeysAndValues,JSONExtractKeysAndValuesRaw,JSONExtractRaw,JSONExtractString,JSONExtractUInt,JSONHas,JSONKey,JSONLength,JSONRemoveDynamoDBAnnotations,JSONType,JSON_ARRAY_LENGTH,JSON_EXISTS,JSON_QUERY,JSON_VALUE,L1Distance,L1Norm,L1Normalize,L2Distance,L2Norm,L2Normalize,L2SquaredDistance,L2SquaredNorm,LAST_DAY,LinfDistance,LinfNorm,LinfNormalize,LpDistance,LpNorm,LpNormalize,MACNumToString,MACStringToNum,MACStringToOUI,MAP_FROM_ARRAYS,MD4,MD5,MILLISECOND,MINUTE,MONTH,OCTET_LENGTH,QUARTER,REGEXP_EXTRACT,REGEXP_MATCHES,REGEXP_REPLACE,SCHEMA,SECOND,SHA1,SHA224,SHA256,SHA384,SHA512,SHA512_256,SUBSTRING_INDEX,SVG,TIMESTAMP_DIFF,TO_BASE64,TO_DAYS,TO_UNIXTIME,ULIDStringToDateTime,URLHash,URLHierarchy,URLPathHierarchy,UTCTimestamp,UTC_timestamp,UUIDNumToString,UUIDStringToNum,UUIDToNum,UUIDv7ToDateTime,YEAR,YYYYMMDDToDate,YYYYMMDDToDate32,YYYYMMDDhhmmssToDateTime,YYYYMMDDhhmmssToDateTime64\\\\n - Character insensitive functions supported are: cast,character_length,char_length,crc32,crc32ieee,crc64,database,date,date_format,date_trunc,day,dayofmonth,dayofweek,dayofyear,format_bytes,fqdn,from_base64,from_days,from_unixtime,hour,inet6_aton,inet6_ntoa,inet_aton,inet_ntoa,json_array_length,last_day,millisecond,minute,month,octet_length,quarter,regexp_extract,regexp_matches,regexp_replace,schema,second,substring_index,to_base64,to_days,to_unixtime,utctimestamp,utc_timestamp,year\\\\n - Aggregate functions supported are: BIT_AND,BIT_OR,BIT_XOR,COVAR_POP,COVAR_SAMP,STD,STDDEV_POP,STDDEV_SAMP,VAR_POP,VAR_SAMP,aggThrow,analysisOfVariance,anova,any,anyHeavy,anyLast,anyLast_respect_nulls,any_respect_nulls,any_value,any_value_respect_nulls,approx_top_count,approx_top_k,approx_top_sum,argMax,argMin,array_agg,array_concat_agg,avg,avgWeighted,boundingRatio,categoricalInformationValue,contingency,corr,corrMatrix,corrStable,count,covarPop,covarPopMatrix,covarPopStable,covarSamp,covarSampMatrix,covarSampStable,cramersV,cramersVBiasCorrected,deltaSum,deltaSumTimestamp,dense_rank,entropy,exponentialMovingAverage,exponentialTimeDecayedAvg,exponentialTimeDecayedCount,exponentialTimeDecayedMax,exponentialTimeDecayedSum,first_value,first_value_respect_nulls,flameGraph,groupArray,groupArrayInsertAt,groupArrayIntersect,groupArrayLast,groupArrayMovingAvg,groupArrayMovingSum,groupArraySample,groupArraySorted,groupBitAnd,groupBitOr,groupBitXor,groupBitmap,groupBitmapAnd,groupBitmapOr,groupBitmapXor,groupUniqArray,histogram,intervalLengthSum,kolmogorovSmirnovTest,kurtPop,kurtSamp,lagInFrame,largestTriangleThreeBuckets,last_value,last_value_respect_nulls,leadInFrame,lttb,mannWhitneyUTest,max,maxIntersections,maxIntersectionsPosition,maxMappedArrays,meanZTest,median,medianBFloat16,medianBFloat16Weighted,medianDD,medianDeterministic,medianExact,medianExactHigh,medianExactLow,medianExactWeighted,medianGK,medianInterpolatedWeighted,medianTDigest,medianTDigestWeighted,medianTiming,medianTimingWeighted,min,minMappedArrays,nonNegativeDerivative,nothing,nothingNull,nothingUInt64,nth_value,ntile,quantile,quantileBFloat16,quantileBFloat16Weighted,quantileDD,quantileDeterministic,quantileExact,quantileExactExclusive,quantileExactHigh,quantileExactInclusive,quantileExactLow,quantileExactWeighted,quantileGK,quantileInterpolatedWeighted,quantileTDigest,quantileTDigestWeighted,quantileTiming,quantileTimingWeighted,quantiles,quantilesBFloat16,quantilesBFloat16Weighted,quantilesDD,quantilesDeterministic,quantilesExact,quantilesExactExclusive,quantilesExactHigh,quantilesExactInclusive,quantilesExactLow,quantilesExactWeighted,quantilesGK,quantilesInterpolatedWeighted,quantilesTDigest,quantilesTDigestWeighted,quantilesTiming,quantilesTimingWeighted,rank,rankCorr,retention,row_number,sequenceCount,sequenceMatch,sequenceNextNode,simpleLinearRegression,singleValueOrNull,skewPop,skewSamp,sparkBar,sparkbar,stddevPop,stddevPopStable,stddevSamp,stddevSampStable,stochasticLinearRegression,stochasticLogisticRegression,studentTTest,sum,sumCount,sumKahan,sumMapFiltered,sumMapFilteredWithOverflow,sumMapWithOverflow,sumMappedArrays,sumWithOverflow,theilsU,topK,topKWeighted,uniq,uniqCombined,uniqCombined64,uniqExact,uniqHLL12,uniqTheta,uniqUpTo,varPop,varPopStable,varSamp,varSampStable,welchTTest,windowFunnel\\\\n - Do not use any function that is not present in the list of general functions, character insensitive functions and aggregate functions.\\\\n - If the function is not present in the list, the sql query will fail, so avoid at all costs to use any function that is not present in the list.\\\\n - When aliasing a column, use first the column name and then the alias.\\\\n - General functions and aggregate functions are case sensitive.\\\\n - Character insensitive functions are case insensitive.\\\\n - Parameters are never quoted in any case.\\\\n - When reading columns with type AggregateFunction(), you need to merge the intermediate states to get the final value.\\\\n - To merge intermediate states, wrap the column in the original aggregation function and apply the `-Merge` combinator.\\\\n - For example, to finalize the value of the `avg_duration_state` column, you use the `avgMerge` function:\\\\n \\\\n SELECT\\\\n date,\\\\n avgMerge(avg_duration_state) avg_time,\\\\n quantilesTimingMerge(0.9, 0.95, 0.99)(quantile_timing_state) quantiles_timing_in_ms_array\\\\n FROM tinybird.pipe_stats\\\\n where pipe_id = 'PIPE_ID'\\\\n group by date\\\\n \\\\n\\\\n\\\"},{\\\"role\\\":\\\"user\\\",\\\"content\\\":\\\"Top 10 longest repository names with at least 1 star. Return the repository name and the repository name length.\\\"}],\\\"stream\\\":true},\\\"statusCode\\\":400,\\\"responseHeaders\\\":{\\\"access-control-allow-origin\\\":\\\"*\\\",\\\"cf-ray\\\":\\\"99f0b4e73f73eb58-ORD\\\",\\\"connection\\\":\\\"keep-alive\\\",\\\"content-type\\\":\\\"application/json\\\",\\\"date\\\":\\\"Sat, 15 Nov 2025 18:10:39 GMT\\\",\\\"permissions-policy\\\":\\\"payment=(self \\\\\\\"https://checkout.stripe.com\\\\\\\" \\\\\\\"https://connect-js.stripe.com\\\\\\\" \\\\\\\"https://js.stripe.com\\\\\\\" \\\\\\\"https://*.js.stripe.com\\\\\\\" \\\\\\\"https://hooks.stripe.com\\\\\\\")\\\",\\\"referrer-policy\\\":\\\"no-referrer, strict-origin-when-cross-origin\\\",\\\"server\\\":\\\"cloudflare\\\",\\\"transfer-encoding\\\":\\\"chunked\\\",\\\"vary\\\":\\\"Accept-Encoding\\\",\\\"x-content-type-options\\\":\\\"nosniff\\\"},\\\"responseBody\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"message\\\\\\\":\\\\\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\\\\\",\\\\\\\"code\\\\\\\":400},\\\\\\\"user_id\\\\\\\":\\\\\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\\\\\"}\\\",\\\"isRetryable\\\":false}\\n```\\n\\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse.\"}],\"stream\":true},\"statusCode\":400,\"responseHeaders\":{\"access-control-allow-origin\":\"*\",\"cf-ray\":\"99f0b4e7dd844fa9-ORD\",\"connection\":\"keep-alive\",\"content-type\":\"application/json\",\"date\":\"Sat, 15 Nov 2025 18:10:39 GMT\",\"permissions-policy\":\"payment=(self \\\"https://checkout.stripe.com\\\" \\\"https://connect-js.stripe.com\\\" \\\"https://js.stripe.com\\\" \\\"https://*.js.stripe.com\\\" \\\"https://hooks.stripe.com\\\")\",\"referrer-policy\":\"no-referrer, strict-origin-when-cross-origin\",\"server\":\"cloudflare\",\"transfer-encoding\":\"chunked\",\"vary\":\"Accept-Encoding\",\"x-content-type-options\":\"nosniff\"},\"responseBody\":\"{\\\"error\\\":{\\\"message\\\":\\\"openrouter/sherlock-think-alpha is not a valid model ID\\\",\\\"code\\\":400},\\\"user_id\\\":\\\"org_2ygOb87hSZF4dzzor70kCxgo7TX\\\"}\",\"isRetryable\":false}\n```\n\nPlease fix the SQL query to correctly answer my original question. Make sure the SQL is valid for Tinybird/ClickHouse." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter" + } + ] + }, + { + "sql": "\nSELECT repo_name\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY repo_name\nHAVING count() >= 1\nORDER BY CHAR_LENGTH(repo_name) ASC, repo_name ASC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "tj/n" + }, + { + "repo_name": "qt/qt" + }, + { + "repo_name": "rf/nd" + }, + { + "repo_name": "rr/rr" + }, + { + "repo_name": "ry/v8" + }, + { + "repo_name": "s4/s4" + }, + { + "repo_name": "sjl/d" + }, + { + "repo_name": "sjl/t" + }, + { + "repo_name": "sm/sm" + }, + { + "repo_name": "sn/sn" + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + } + ], + "statistics": { + "elapsed": 0.056123675, + "rows_read": 7321600, + "bytes_read": 35699881 + }, + "executionTime": 0.158, + "requestId": "01KA4BCV6RJMG1P3YK81E0P6BB", + "length": 220 + }, + "name": "pipe_50.pipe", + "question": { + "name": "pipe_50.pipe", + "content": "DESCRIPTION >\n Top 10 shortest repository names with at least 1 star. Only return the repository name.\n\nNODE endpoint\nSQL >\n SELECT repo_name FROM github_events WHERE event_type = 'WatchEvent' AND repo_name LIKE '%_/_%' GROUP BY repo_name ORDER BY length(repo_name) ASC LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 shortest repository names with at least 1 star. Only return the repository name." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.374, + "totalDuration": 5.75, + "tokens": { + "promptTokens": 4592, + "completionTokens": 726, + "totalTokens": 5318 + } + }, + "error": null, + "attempts": [ + { + "sql": "\nSELECT repo_name\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY repo_name\nHAVING count() >= 1\nORDER BY CHAR_LENGTH(repo_name) ASC, repo_name ASC\nLIMIT 10\n", + "sqlResult": { + "success": true, + "data": [ + { + "repo_name": "tj/n" + }, + { + "repo_name": "qt/qt" + }, + { + "repo_name": "rf/nd" + }, + { + "repo_name": "rr/rr" + }, + { + "repo_name": "ry/v8" + }, + { + "repo_name": "s4/s4" + }, + { + "repo_name": "sjl/d" + }, + { + "repo_name": "sjl/t" + }, + { + "repo_name": "sm/sm" + }, + { + "repo_name": "sn/sn" + } + ], + "meta": [ + { + "name": "repo_name", + "type": "LowCardinality(String)" + } + ], + "statistics": { + "elapsed": 0.056123675, + "rows_read": 7321600, + "bytes_read": 35699881 + }, + "executionTime": 0.158, + "requestId": "01KA4BCV6RJMG1P3YK81E0P6BB", + "length": 220 + }, + "name": "pipe_50.pipe", + "question": { + "name": "pipe_50.pipe", + "content": "DESCRIPTION >\n Top 10 shortest repository names with at least 1 star. Only return the repository name.\n\nNODE endpoint\nSQL >\n SELECT repo_name FROM github_events WHERE event_type = 'WatchEvent' AND repo_name LIKE '%_/_%' GROUP BY repo_name ORDER BY length(repo_name) ASC LIMIT 10\n\nTYPE endpoint", + "question": "Top 10 shortest repository names with at least 1 star. Only return the repository name." + }, + "model": "sherlock-think-alpha", + "provider": "openrouter", + "metrics": { + "timeToFirstToken": 0.374, + "totalDuration": 5.75, + "tokens": { + "promptTokens": 4592, + "completionTokens": 726, + "totalTokens": 5318 + } + }, + "error": null + } + ] } ] \ No newline at end of file diff --git a/src/benchmark/validation-results.json b/src/benchmark/validation-results.json index 7a262b3..5df5b48 100644 --- a/src/benchmark/validation-results.json +++ b/src/benchmark/validation-results.json @@ -924,6 +924,20 @@ "humanRowCount": 1, "llmRowCount": 1, "sql": "\nSELECT count() as total_stars\nFROM github_events\nWHERE event_type = 'WatchEvent'\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 1, + "llmRowCount": 1, + "sql": "\nSELECT count() FROM github_events WHERE event_type = 'WatchEvent' LIMIT 10\n" } }, "humanResults": { @@ -2855,6 +2869,20 @@ "humanRowCount": 5, "llmRowCount": 5, "sql": "\nSELECT\n pow(10, floor(log10(stars + 1))) as star_bucket,\n count(DISTINCT repo_name) as repo_count\nFROM (\n SELECT \n repo_name,\n count() as stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n)\nWHERE stars > 0\nGROUP BY star_bucket\nORDER BY star_bucket ASC\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 5, + "llmRowCount": 5, + "sql": "\nSELECT\n approx_stars,\n count() AS num_repos\nFROM (\n SELECT\n CASE\n WHEN count() < 10 THEN 1\n WHEN count() < 100 THEN 10\n WHEN count() < 1000 THEN 100\n WHEN count() < 10000 THEN 1000\n WHEN count() < 100000 THEN 10000\n WHEN count() < 1000000 THEN 100000\n WHEN count() < 10000000 THEN 1000000\n ELSE 10000000\n END AS approx_stars\n FROM github_events\n WHERE event_type = 'WatchEvent'\n GROUP BY repo_name\n) AS repo_buckets\nGROUP BY approx_stars\nORDER BY approx_stars ASC\nLIMIT 10\n" } }, "humanResults": { @@ -4770,6 +4798,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n toYear(created_at) as year,\n repo_name,\n count() as events_count\nFROM github_events\nWHERE toYear(created_at) >= 2015\nGROUP BY year, repo_name\nORDER BY year ASC, events_count DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 0.5, + "numeric": 0.4884875640384983, + "fScore": 0.6666666666666666 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 20, + "sql": "\nSELECT\n YEAR(created_at) AS year,\n repo_name,\n count() AS stars\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND action = 'started'\n AND created_at >= '2015-01-01'\n AND repo_name != ''\nGROUP BY year, repo_name\nORDER BY year ASC, stars DESC\nLIMIT 10 BY year\nLIMIT 100\n" } }, "humanResults": { @@ -6714,6 +6756,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n actor_login,\n COUNT(*) as star_count\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY actor_login\nORDER BY star_count DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "SELECT\n actor_login,\n count() AS stars_given\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY actor_login\nORDER BY stars_given DESC\nLIMIT 10" } }, "humanResults": { @@ -7704,6 +7760,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n COUNT(*) as star_count\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND actor_login IN (\n SELECT DISTINCT actor_login\n FROM github_events\n WHERE event_type = 'WatchEvent'\n AND repo_name = 'tensorflow/tensorflow'\n )\n AND repo_name != 'tensorflow/tensorflow'\nGROUP BY repo_name\nORDER BY star_count DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 1, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT \n e2.repo_name AS repo_name,\n count() AS stars_count\nFROM github_events AS e1\nINNER JOIN github_events AS e2 ON e1.actor_login = e2.actor_login\nWHERE \n e1.event_type = 'WatchEvent' \n AND e1.action = 'started' \n AND e1.repo_name = 'tensorflow/tensorflow'\n AND e2.event_type = 'WatchEvent' \n AND e2.action = 'started' \n AND e2.repo_name != 'tensorflow/tensorflow'\nGROUP BY e2.repo_name\nORDER BY stars_count DESC\nLIMIT 10\n" } }, "humanResults": { @@ -9684,6 +9754,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n uniq(actor_login) as unique_tf_contributors,\n count() as total_prs\nFROM github_events\nWHERE event_type = 'PullRequestEvent'\n AND action = 'opened'\n AND actor_login IN (\n SELECT DISTINCT actor_login \n FROM github_events \n WHERE event_type = 'PullRequestEvent' \n AND repo_name LIKE '%tensorflow%'\n AND action = 'opened'\n )\n AND repo_name NOT LIKE '%tensorflow%'\nGROUP BY repo_name\nORDER BY unique_tf_contributors DESC, total_prs DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 0.18095166080355407, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n pr.repo_name,\n countDistinct(pr.actor_login) AS unique_tf_contributors\nFROM github_events AS pr\nINNER JOIN github_events AS tf\nON pr.actor_login = tf.actor_login\nWHERE pr.event_type = 'PullRequestEvent'\n AND pr.action = 'opened'\n AND pr.repo_name != 'tensorflow/tensorflow'\n AND tf.event_type = 'PullRequestEvent'\n AND tf.action = 'opened'\n AND tf.repo_name = 'tensorflow/tensorflow'\nGROUP BY pr.repo_name\nORDER BY unique_tf_contributors DESC\nLIMIT 10\n" } }, "humanResults": { @@ -10670,6 +10754,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n actor_login,\n COUNT(*) as issue_count\nFROM github_events\nWHERE event_type = 'IssuesEvent'\n AND action = 'opened'\n AND actor_login IN (\n SELECT DISTINCT actor_login \n FROM github_events \n WHERE event_type = 'IssuesEvent' \n AND action = 'opened'\n AND repo_name = 'tensorflow/tensorflow'\n )\n AND repo_name != 'tensorflow/tensorflow'\nGROUP BY repo_name, actor_login\nORDER BY issue_count DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 0.921366691261145, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "SELECT\n repo_name,\n count(*) AS issue_count\nFROM github_events\nWHERE event_type = 'IssuesEvent'\n AND action = 'opened'\n AND repo_name != 'tensorflow/tensorflow'\n AND actor_login IN (\n SELECT actor_login\n FROM github_events\n WHERE event_type = 'IssuesEvent'\n AND action = 'opened'\n AND repo_name = 'tensorflow/tensorflow'\n GROUP BY actor_login\n )\nGROUP BY repo_name\nORDER BY issue_count DESC\nLIMIT 10" } }, "humanResults": { @@ -14684,6 +14782,20 @@ "humanRowCount": 10, "llmRowCount": 0, "sql": "\nSELECT \n repo_name,\n COUNT(*) as total_stars,\n toStartOfMonth(created_at) as month,\n COUNT(*) / COUNT(DISTINCT toStartOfMonth(created_at)) as avg_stars_per_month,\n stddevPop(COUNT(*)) OVER (PARTITION BY repo_name) as star_growth_stddev\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND created_at >= now() - INTERVAL 1 YEAR\nGROUP BY repo_name, month\nHAVING COUNT(DISTINCT month) >= 6\nORDER BY star_growth_stddev ASC, total_stars DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 1, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 0, + "sql": "\nSELECT\n repo_name,\n count() AS total_stars,\n STDDEV_POP(CAST(created_at AS UInt32)) AS std_ts,\n CAST(max(created_at) AS UInt32) - CAST(min(created_at) AS UInt32) AS span_seconds,\n STDDEV_POP(CAST(created_at AS UInt32)) * 3.46410161514 / (CAST(max(created_at) AS UInt32) - CAST(min(created_at) AS UInt32) + 1e-9) AS steadiness_ratio\nFROM github_events\nWHERE event_type = 'WatchEvent'\n AND created_at >= now() - INTERVAL 1 YEAR\nGROUP BY repo_name\nHAVING total_stars >= 100\n AND span_seconds > 0\nORDER BY steadiness_ratio DESC, total_stars DESC\nLIMIT 10\n" } }, "humanResults": { @@ -16658,6 +16770,20 @@ "humanRowCount": 1, "llmRowCount": 1, "sql": "\nSELECT count(DISTINCT actor_login) as total_users\nFROM github_events\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": false, + "numericMatches": true, + "distance": { + "exact": 1, + "numeric": 0.000052934128674804696, + "fScore": 0 + }, + "details": "Results match within numeric threshold", + "humanRowCount": 1, + "llmRowCount": 1, + "sql": "\nSELECT uniqExact(actor_login) AS total_users FROM github_events LIMIT 10\n" } }, "humanResults": { @@ -18528,6 +18654,20 @@ "humanRowCount": 1, "llmRowCount": 1, "sql": "\nSELECT count(DISTINCT actor_login) as total_users\nFROM github_events\nWHERE event_type = 'PushEvent'\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": false, + "numericMatches": true, + "distance": { + "exact": 1, + "numeric": 0.0018759619527295886, + "fScore": 0 + }, + "details": "Results match within numeric threshold", + "humanRowCount": 1, + "llmRowCount": 1, + "sql": "\nSELECT countDistinct(actor_login) FROM github_events WHERE event_type = 'PushEvent' LIMIT 10\n" } }, "humanResults": { @@ -21362,6 +21502,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n count() as pr_count\nFROM github_events\nWHERE event_type = 'PullRequestEvent'\n AND action = 'opened'\nGROUP BY repo_name, actor_login\nHAVING count() >= 10\nORDER BY pr_count DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 1, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "SELECT repo_name, sum(pr_count) AS total_prs_by_prolific_authors FROM (SELECT repo_name, actor_login, count() AS pr_count FROM github_events WHERE event_type = 'PullRequestEvent' AND action = 'opened' GROUP BY repo_name, actor_login HAVING pr_count >= 10) GROUP BY repo_name ORDER BY total_prs_by_prolific_authors DESC LIMIT 10" } }, "humanResults": { @@ -23328,6 +23482,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n uniq(actor_login) as unique_contributors\nFROM github_events\nWHERE event_type = 'PullRequestEvent'\n AND action = 'opened'\nGROUP BY repo_name\nORDER BY unique_contributors DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n repo_name,\n count(distinct actor_login) AS pr_contributors\nFROM github_events\nWHERE event_type = 'PullRequestEvent' AND action = 'opened'\nGROUP BY repo_name\nORDER BY pr_contributors DESC\nLIMIT 10\n" } }, "humanResults": { @@ -26266,6 +26434,20 @@ "humanRowCount": 10, "llmRowCount": 0, "sql": "\nSELECT \n repo_name,\n uniq(actor_login) as unique_pushers\nFROM github_events\nWHERE event_type = 'PushEvent'\n AND base_ref = 'refs/heads/main'\nGROUP BY repo_name\nORDER BY unique_pushers DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 1, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n repo_name,\n countDistinct(actor_login) AS pushers_count\nFROM github_events\nWHERE event_type = 'PushEvent'\n AND ref = 'refs/heads/main'\nGROUP BY repo_name\nORDER BY pushers_count DESC\nLIMIT 10\n" } }, "humanResults": { @@ -30222,6 +30404,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n countIf(event_type = 'WatchEvent') as stars,\n countIf(event_type = 'ForkEvent') as forks,\n stars / nullIf(forks, 0) as star_fork_ratio\nFROM github_events\nWHERE event_type IN ('WatchEvent', 'ForkEvent')\nGROUP BY repo_name\nHAVING forks > 0\nORDER BY star_fork_ratio DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 1, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n repo_name,\n sum(event_type = 'WatchEvent') AS stars,\n sum(event_type = 'ForkEvent') AS forks,\n sum(event_type = 'WatchEvent') / sum(event_type = 'ForkEvent') AS star_fork_ratio\nFROM github_events\nWHERE event_type IN ('WatchEvent', 'ForkEvent')\nGROUP BY repo_name\nHAVING sum(event_type = 'ForkEvent') > 0\nORDER BY star_fork_ratio DESC\nLIMIT 10\n" } }, "humanResults": { @@ -31226,6 +31422,20 @@ "humanRowCount": 1, "llmRowCount": 1, "sql": "\nSELECT\n countIf(event_type = 'WatchEvent') AS total_stars,\n countIf(event_type = 'ForkEvent') AS total_forks,\n round(countIf(event_type = 'WatchEvent') / countIf(event_type = 'ForkEvent'), 2) AS stars_to_forks_ratio\nFROM github_events\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": false, + "numericMatches": true, + "distance": { + "exact": 1, + "numeric": 0.004424139993790239, + "fScore": 0 + }, + "details": "Results match within numeric threshold", + "humanRowCount": 1, + "llmRowCount": 1, + "sql": "\nSELECT\n sum((event_type = 'WatchEvent')) AS stars,\n sum((event_type = 'ForkEvent')) AS forks,\n CAST(sum((event_type = 'WatchEvent')) * 1.0 / sum((event_type = 'ForkEvent')) AS Decimal(20, 2)) AS ratio\nFROM github_events\nLIMIT 10\n" } }, "humanResults": { @@ -32157,6 +32367,20 @@ "humanRowCount": 1, "llmRowCount": 1, "sql": "\nSELECT count() as total_issues\nFROM github_events\nWHERE event_type = 'IssuesEvent'\nAND action = 'opened'\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 1, + "llmRowCount": 1, + "sql": "\nSELECT COUNT(*) FROM github_events WHERE event_type = 'IssuesEvent' AND action = 'opened' LIMIT 10\n" } }, "humanResults": { @@ -34078,6 +34302,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n countIf(event_type = 'IssueCommentEvent') as issue_comments,\n countIf(event_type = 'IssuesEvent' AND action = 'opened') as issues_opened,\n if(issues_opened > 0, issue_comments / issues_opened, 0) as comment_to_issue_ratio\nFROM github_events\nWHERE event_type IN ('IssueCommentEvent', 'IssuesEvent')\nGROUP BY repo_name\nHAVING issues_opened > 0\nORDER BY comment_to_issue_ratio DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 1, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n repo_name,\n countIf(event_type = 'IssueCommentEvent') AS num_comments,\n countIf(event_type = 'IssuesEvent' AND action = 'opened') AS num_issues,\n num_comments / num_issues AS ratio\nFROM github_events\nGROUP BY repo_name\nHAVING num_issues > 0\nORDER BY ratio DESC\nLIMIT 10\n" } }, "humanResults": { @@ -38058,6 +38296,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n count() as commit_comments\nFROM github_events\nWHERE event_type = 'CommitCommentEvent'\nGROUP BY repo_name\nORDER BY commit_comments DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "SELECT\n repo_name,\n count() AS num_commit_comments\nFROM github_events\nWHERE event_type = 'CommitCommentEvent'\nGROUP BY repo_name\nORDER BY num_commit_comments DESC\nLIMIT 10" } }, "humanResults": { @@ -40052,6 +40304,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n concat('https://github.com/', repo_name, '/pull/', toString(number)) AS pr_url,\n uniq(actor_login) AS unique_authors\nFROM github_events\nWHERE event_type = 'PullRequestReviewCommentEvent'\n AND number > 0\nGROUP BY repo_name, number\nORDER BY unique_authors DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": false, + "numericMatches": true, + "distance": { + "exact": 0.33333333333333337, + "numeric": 0, + "fScore": 0.8000000000000002 + }, + "details": "Results match within numeric threshold", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n 'https://github.com/' || repo_name || '/pull/' || CAST(number AS String) AS pr_url,\n uniqExact(actor_login) AS unique_authors\nFROM github_events\nWHERE event_type = 'PullRequestReviewCommentEvent'\nGROUP BY repo_name, number\nORDER BY unique_authors DESC\nLIMIT 10\n" } }, "humanResults": { @@ -41042,6 +41308,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n actor_login,\n COUNT(*) as push_count\nFROM github_events\nWHERE event_type = 'PushEvent'\nGROUP BY actor_login\nORDER BY push_count DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n actor_login,\n count() AS pushes\nFROM github_events\nWHERE event_type = 'PushEvent'\nGROUP BY actor_login\nORDER BY pushes DESC\nLIMIT 10\n" } }, "humanResults": { @@ -42032,6 +42312,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n splitByChar('/', repo_name)[1] AS organization,\n count() AS stars\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY organization\nORDER BY stars DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": false, + "numericMatches": true, + "distance": { + "exact": 1, + "numeric": 0, + "fScore": 0 + }, + "details": "Results match within numeric threshold", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n substringIndex(repo_name, '/', 1) AS owner,\n count() AS stars\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY owner\nORDER BY stars DESC\nLIMIT 10\n" } }, "humanResults": { @@ -43008,6 +43302,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n splitByChar('/', repo_name)[1] AS organization,\n uniqExact(repo_name) AS repository_count\nFROM github_events\nGROUP BY organization\nORDER BY repository_count DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 1, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n substringIndex(repo_name, '/', 1) AS org_name,\n count(DISTINCT repo_name) AS repo_count\nFROM github_events\nWHERE repo_name != ''\nGROUP BY org_name\nORDER BY repo_count DESC\nLIMIT 10\n" } }, "humanResults": { @@ -43998,6 +44306,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n repo_name,\n count() as pr_count,\n uniq(actor_login) as unique_authors,\n sum(additions) as total_adds,\n sum(deletions) as total_dels,\n sum(additions + deletions) as total_churn\nFROM github_events\nWHERE event_type = 'PullRequestEvent'\n AND action = 'opened'\n AND additions < 10000\n AND deletions < 10000\nGROUP BY repo_name\nORDER BY total_churn DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n repo_name,\n count() AS pr_count,\n uniqExact(actor_login) AS unique_authors,\n sum(additions) AS total_adds,\n sum(deletions) AS total_dels\nFROM github_events\nWHERE event_type = 'PullRequestEvent'\n AND action = 'opened'\n AND additions < 10000\n AND deletions < 10000\nGROUP BY repo_name\nORDER BY sum(additions) + sum(deletions) DESC\nLIMIT 10\n" } }, "humanResults": { @@ -45030,6 +45352,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n actor_login as author,\n count() as total_pr_comments,\n uniq(repo_name) as unique_repositories,\n uniq(number) as unique_prs\nFROM github_events\nWHERE event_type = 'PullRequestReviewCommentEvent'\n AND action = 'created'\nGROUP BY actor_login\nORDER BY total_pr_comments DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": true, + "exactMatches": true, + "numericMatches": true, + "distance": { + "exact": 0, + "numeric": 0, + "fScore": 1 + }, + "details": "Results match within exact threshold", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n actor_login AS author,\n count(*) AS num_comments,\n countDistinct(repo_name) AS unique_repos,\n countDistinct(tuple(repo_name, number)) AS unique_prs\nFROM github_events\nWHERE event_type = 'PullRequestReviewCommentEvent' AND action = 'created'\nGROUP BY actor_login\nORDER BY num_comments DESC\nLIMIT 10\n" } }, "humanResults": { @@ -47006,6 +47342,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT \n splitByChar('/', repo_name)[1] as organization,\n uniq(actor_login) as unique_authors,\n uniqIf(actor_login, event_type = 'PullRequestEvent' AND action = 'opened') as unique_pr_authors,\n uniqIf(actor_login, event_type = 'IssuesEvent' AND action = 'opened') as unique_issue_authors,\n uniqIf(actor_login, event_type = 'IssueCommentEvent') as unique_issue_comment_authors,\n uniqIf(actor_login, event_type = 'PushEvent') as unique_push_authors\nFROM github_events\nWHERE repo_name != ''\nGROUP BY organization\nORDER BY unique_authors DESC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 1, + "numeric": 1, + "fScore": 0 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT\n SUBSTRING_INDEX(repo_name, '/', 1) AS organization_name,\n uniqExact(actor_login) AS unique_authors,\n uniqExact(if(event_type='PullRequestEvent' AND action='opened', actor_login, NULL)) AS unique_pull_request_authors,\n uniqExact(if(event_type='IssuesEvent' AND action='opened', actor_login, NULL)) AS unique_issue_authors,\n uniqExact(if(event_type='IssueCommentEvent', actor_login, NULL)) AS unique_issue_comment_authors,\n uniqExact(if(event_type='PushEvent', actor_login, NULL)) AS unique_push_authors\nFROM github_events\nWHERE repo_name != ''\nGROUP BY organization_name\nHAVING organization_name != ''\nORDER BY unique_authors DESC\nLIMIT 10\n" } }, "humanResults": { @@ -49042,6 +49392,20 @@ "humanRowCount": 10, "llmRowCount": 10, "sql": "\nSELECT repo_name\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY repo_name\nHAVING count() >= 1\nORDER BY length(repo_name) ASC\nLIMIT 10\n" + }, + "openrouter/sherlock-think-alpha": { + "matches": false, + "exactMatches": false, + "numericMatches": false, + "distance": { + "exact": 0.75, + "numeric": 1, + "fScore": 0.40000000000000013 + }, + "details": "Results don't match", + "humanRowCount": 10, + "llmRowCount": 10, + "sql": "\nSELECT repo_name\nFROM github_events\nWHERE event_type = 'WatchEvent'\nGROUP BY repo_name\nHAVING count() >= 1\nORDER BY CHAR_LENGTH(repo_name) ASC, repo_name ASC\nLIMIT 10\n" } }, "humanResults": { @@ -49623,6 +49987,14 @@ "avgExactDistance": 0.5383838383838385, "avgNumericDistance": 0.39462101454809, "avgFScore": 0.4699999999999999 + }, + "openrouter/sherlock-think-alpha": { + "totalMatches": 14, + "exactMatches": 9, + "numericMatches": 14, + "avgExactDistance": 0.3116666666666667, + "avgNumericDistance": 0.21194317904356785, + "avgFScore": 0.2173333333333333 } } }