Skip to content

Commit 1451ca5

Browse files
committed
Add missing aggregate functions and cast() to functions list
1 parent 82ae08f commit 1451ca5

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

src/languages/tidb/tidb.functions.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export const functions: string[] = [
22
// https://docs.pingcap.com/tidb/stable/sql-statement-show-builtins
33
// https://docs.pingcap.com/tidb/stable/functions-and-operators-overview
4+
// + MySQL aggregate functions: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html
5+
// + MySQL window functions: https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html
46
'ABS',
57
'ACOS',
68
'ADDDATE',
@@ -13,16 +15,21 @@ export const functions: string[] = [
1315
'ASIN',
1416
'ATAN',
1517
'ATAN2',
18+
'AVG',
1619
'BENCHMARK',
1720
'BIN',
1821
'BIN_TO_UUID',
22+
'BIT_AND',
1923
'BIT_COUNT',
2024
'BIT_LENGTH',
25+
'BIT_OR',
26+
'BIT_XOR',
2127
'BITAND',
2228
'BITNEG',
2329
'BITOR',
2430
'BITXOR',
2531
'CASE',
32+
'CAST',
2633
'CEIL',
2734
'CEILING',
2835
'CHAR_FUNC',
@@ -41,7 +48,9 @@ export const functions: string[] = [
4148
'CONVERT_TZ',
4249
'COS',
4350
'COT',
51+
'COUNT',
4452
'CRC32',
53+
'CUME_DIST',
4554
'CURDATE',
4655
'CURRENT_DATE',
4756
'CURRENT_RESOURCE_GROUP',
@@ -64,6 +73,7 @@ export const functions: string[] = [
6473
'DECODE',
6574
'DEFAULT_FUNC',
6675
'DEGREES',
76+
'DENSE_RANK',
6777
'DES_DECRYPT',
6878
'DES_ENCRYPT',
6979
'DIV',
@@ -76,6 +86,7 @@ export const functions: string[] = [
7686
'EXTRACT',
7787
'FIELD',
7888
'FIND_IN_SET',
89+
'FIRST_VALUE',
7990
'FLOOR',
8091
'FORMAT',
8192
'FORMAT_BYTES',
@@ -89,6 +100,7 @@ export const functions: string[] = [
89100
'GET_LOCK',
90101
'GETPARAM',
91102
'GREATEST',
103+
'GROUP_CONCAT',
92104
'GROUPING',
93105
'GT',
94106
'HEX',
@@ -116,6 +128,7 @@ export const functions: string[] = [
116128
'ISNULL',
117129
'ISTRUE',
118130
'JSON_ARRAY',
131+
'JSON_ARRAYAGG',
119132
'JSON_ARRAY_APPEND',
120133
'JSON_ARRAY_INSERT',
121134
'JSON_CONTAINS',
@@ -130,6 +143,7 @@ export const functions: string[] = [
130143
'JSON_MERGE_PATCH',
131144
'JSON_MERGE_PRESERVE',
132145
'JSON_OBJECT',
146+
'JSON_OBJECTAGG',
133147
'JSON_OVERLAPS',
134148
'JSON_PRETTY',
135149
'JSON_QUOTE',
@@ -142,11 +156,14 @@ export const functions: string[] = [
142156
'JSON_TYPE',
143157
'JSON_UNQUOTE',
144158
'JSON_VALID',
159+
'LAG',
145160
'LAST_DAY',
146161
'LAST_INSERT_ID',
162+
'LAST_VALUE',
147163
'LASTVAL',
148164
'LCASE',
149165
'LE',
166+
'LEAD',
150167
'LEAST',
151168
'LEFT',
152169
'LEFTSHIFT',
@@ -168,9 +185,11 @@ export const functions: string[] = [
168185
'MAKEDATE',
169186
'MAKETIME',
170187
'MASTER_POS_WAIT',
188+
'MAX',
171189
'MD5',
172190
'MICROSECOND',
173191
'MID',
192+
'MIN',
174193
'MINUS',
175194
'MINUTE',
176195
'MOD',
@@ -182,13 +201,16 @@ export const functions: string[] = [
182201
'NEXTVAL',
183202
'NOT',
184203
'NOW',
204+
'NTH_VALUE',
205+
'NTILE',
185206
'NULLEQ',
186207
'OCT',
187208
'OCTET_LENGTH',
188209
'OLD_PASSWORD',
189210
// 'OR',
190211
'ORD',
191212
'PASSWORD_FUNC',
213+
'PERCENT_RANK',
192214
'PERIOD_ADD',
193215
'PERIOD_DIFF',
194216
'PI',
@@ -201,6 +223,7 @@ export const functions: string[] = [
201223
'RADIANS',
202224
'RAND',
203225
'RANDOM_BYTES',
226+
'RANK',
204227
'REGEXP',
205228
'REGEXP_INSTR',
206229
'REGEXP_LIKE',
@@ -215,6 +238,7 @@ export const functions: string[] = [
215238
'RIGHTSHIFT',
216239
'ROUND',
217240
'ROW_COUNT',
241+
'ROW_NUMBER',
218242
'RPAD',
219243
'RTRIM',
220244
'SCHEMA',
@@ -232,13 +256,18 @@ export const functions: string[] = [
232256
'SM3',
233257
'SPACE',
234258
'SQRT',
259+
'STD',
260+
'STDDEV',
261+
'STDDEV_POP',
262+
'STDDEV_SAMP',
235263
'STR_TO_DATE',
236264
'STRCMP',
237265
'SUBDATE',
238266
'SUBSTR',
239267
'SUBSTRING',
240268
'SUBSTRING_INDEX',
241269
'SUBTIME',
270+
'SUM',
242271
'SYSDATE',
243272
'SYSTEM_USER',
244273
'TAN',
@@ -283,6 +312,9 @@ export const functions: string[] = [
283312
'UUID_SHORT',
284313
'UUID_TO_BIN',
285314
'VALIDATE_PASSWORD_STRENGTH',
315+
'VAR_POP',
316+
'VAR_SAMP',
317+
'VARIANCE',
286318
'VERSION',
287319
'VITESS_HASH',
288320
'WEEK',

src/languages/tidb/tidb.keywords.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export const keywords: string[] = [
2323
'CONVERT', // (R)
2424
'CREATE', // (R)
2525
'CROSS', // (R)
26-
'CUME_DIST', // (R)
2726
'CURRENT_DATE', // (R)
2827
'CURRENT_ROLE', // (R)
2928
'CURRENT_TIME', // (R)
@@ -39,7 +38,6 @@ export const keywords: string[] = [
3938
'DEFAULT', // (R)
4039
'DELAYED', // (R)
4140
'DELETE', // (R)
42-
'DENSE_RANK', // (R)
4341
'DESC', // (R)
4442
'DESCRIBE', // (R)
4543
'DISTINCT', // (R)
@@ -58,7 +56,6 @@ export const keywords: string[] = [
5856
'EXPLAIN', // (R)
5957
'FALSE', // (R)
6058
'FETCH', // (R)
61-
'FIRST_VALUE', // (R)
6259
'FOR', // (R)
6360
'FORCE', // (R)
6461
'FOREIGN', // (R)
@@ -91,9 +88,6 @@ export const keywords: string[] = [
9188
'KEY', // (R)
9289
'KEYS', // (R)
9390
'KILL', // (R)
94-
'LAG', // (R)
95-
'LAST_VALUE', // (R)
96-
'LEAD', // (R)
9791
'LEADING', // (R)
9892
'LEAVE', // (R)
9993
'LEFT', // (R)
@@ -115,8 +109,6 @@ export const keywords: string[] = [
115109
'NATURAL', // (R)
116110
'NOT', // (R)
117111
'NO_WRITE_TO_BINLOG', // (R)
118-
'NTH_VALUE', // (R)
119-
'NTILE', // (R)
120112
'NULL', // (R)
121113
'OF', // (R)
122114
'ON', // (R)
@@ -130,11 +122,9 @@ export const keywords: string[] = [
130122
'OUTFILE', // (R)
131123
'OVER', // (R)
132124
'PARTITION', // (R)
133-
'PERCENT_RANK', // (R)
134125
'PRIMARY', // (R)
135126
'PROCEDURE', // (R)
136127
'RANGE', // (R)
137-
'RANK', // (R)
138128
'READ', // (R)
139129
'RECURSIVE', // (R)
140130
'REFERENCES', // (R)
@@ -150,7 +140,6 @@ export const keywords: string[] = [
150140
'RLIKE', // (R)
151141
'ROW', // (R)
152142
'ROWS', // (R)
153-
'ROW_NUMBER', // (R)
154143
'SECOND_MICROSECOND', // (R)
155144
'SELECT', // (R)
156145
'SET', // (R)

0 commit comments

Comments
 (0)