Skip to content

Commit

Permalink
feat: add aggregate function tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Jul 29, 2024
1 parent 34aa8db commit f5fea80
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/drivers/sqlite/function-tooltip.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"syntax": "abs(X)",
"description": "<p>Returns the absolute value of X. If X is a string or blob, it returns 0.</p>\n<pre><code>SELECT abs(-5); --&gt; 5\nSELECT abs(\"-3\"); --&gt; 3\nSELECT abs(\"libsql\"); --&gt; 0\n</code></pre>"
},
"avg": {
"syntax": "avg(X)",
"description": "<p>The avg() function returns the average of all non-NULL values in a group, interpreting non-numeric\nstrings and BLOBs as 0. It always yields a floating point result if there is at least one non-NULL\ninput and returns NULL if there are no non-NULL inputs.</p>"
},
"changes": {
"syntax": "changes()",
"description": "<p>The changes() function returns the number of rows altered by the latest INSERT, DELETE, or UPDATE statement, excluding changes from lower-level triggers.</p>"
Expand All @@ -23,6 +27,10 @@
"syntax": "concat_ws(SEP,X,...)",
"description": "<p>The concat_ws concatenates all non-null arguments beyond the first, using the first argument as a separator. If the first argument is NULL, it returns NULL. If all other arguments are NULL, it returns an empty string.</p>\n<pre><code>select concat_ws(', ', 'hello', 'world')\n-&gt; 'hello world'\n</code></pre>"
},
"count": {
"syntax": "count(X), count(\\*)",
"description": "<p>The count(X) function returns a count of the number of times that X is not NULL in a group.\nThe count(*) function (with no arguments) returns the total number of rows in the group.</p>"
},
"format": {
"syntax": "format(FORMAT,...)",
"description": "<p>The FORMAT() function, similar to C's printf(), uses a format string (first argument) to construct the output with values from subsequent arguments.</p>\n<pre><code>select format('i am %d years old', 50);\n-&gt; 'i am 50 years old'\n</code></pre>"
Expand All @@ -35,6 +43,10 @@
"syntax": "glob(X,Y)",
"description": "<p>The GLOB operator is like LIKE but uses Unix file globbing syntax and is case-sensitive.</p>\n<pre><code>select glob('*hello*', 'hello world');\n-&gt; 1\n</code></pre>"
},
"group_concat": {
"syntax": "group_concat(X, Y)",
"description": "<p>The function concatenates all non-NULL values of X into a string, using Y as the separator. If Y is omitted, a comma (\",\") is used.</p>"
},
"hex": {
"syntax": "hex(X)",
"description": "<p>The hex() function converts its BLOB argument into an upper-case hexadecimal string.</p>\n<pre><code>select hex(x'ffeeaa');\n-&gt; FFEEAA\n</code></pre>"
Expand Down Expand Up @@ -118,5 +130,17 @@
"sign": {
"syntax": "sign(X)",
"description": "<p>The sign(X) function returns -1, 0, or 1 if X is negative, zero, or positive, respectively. If X is NULL or not a number, it returns NULL.</p>\n<pre><code>select sign(-5); -&gt; -1\nselect sign(0); -&gt; 0\nselect sign(5); -&gt; 1\n</code></pre>"
},
"string_agg": {
"syntax": "string_agg(X, Y)",
"description": "<p>The function concatenates all non-NULL values of X into a string, using Y as the separator. If Y is omitted, a comma (\",\") is used.</p>"
},
"sum": {
"syntax": "sum(X)",
"description": "<p>The function returns the sum of all non-NULL values in the group, returning NULL if there are no non-NULL inputs.</p>"
},
"total": {
"syntax": "total(X)",
"description": "<p>The function returns the sum of all non-NULL values in the group, with a result of 0.0 if there are no non-NULL inputs.\nThe result of total() is always a floating point value.</p>"
}
}
5 changes: 5 additions & 0 deletions src/drivers/sqlite/functions/avg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
avg(X)

The avg() function returns the average of all non-NULL values in a group, interpreting non-numeric
strings and BLOBs as 0. It always yields a floating point result if there is at least one non-NULL
input and returns NULL if there are no non-NULL inputs.
4 changes: 4 additions & 0 deletions src/drivers/sqlite/functions/count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
count(X), count(\*)

The count(X) function returns a count of the number of times that X is not NULL in a group.
The count(\*) function (with no arguments) returns the total number of rows in the group.
3 changes: 3 additions & 0 deletions src/drivers/sqlite/functions/group_concat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
group_concat(X, Y)

The function concatenates all non-NULL values of X into a string, using Y as the separator. If Y is omitted, a comma (",") is used.
3 changes: 3 additions & 0 deletions src/drivers/sqlite/functions/string_agg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
string_agg(X, Y)

The function concatenates all non-NULL values of X into a string, using Y as the separator. If Y is omitted, a comma (",") is used.
3 changes: 3 additions & 0 deletions src/drivers/sqlite/functions/sum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sum(X)

The function returns the sum of all non-NULL values in the group, returning NULL if there are no non-NULL inputs.
4 changes: 4 additions & 0 deletions src/drivers/sqlite/functions/total.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
total(X)

The function returns the sum of all non-NULL values in the group, with a result of 0.0 if there are no non-NULL inputs.
The result of total() is always a floating point value.

0 comments on commit f5fea80

Please sign in to comment.