kusto.ts 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. /* tslint:disable:max-line-length */
  2. export const operatorTokens = [
  3. { text: '!between', hint: 'Matches the input that is outside the inclusive range.' },
  4. { text: 'as', hint: "Binds a name to the operator's input tabular expression." },
  5. { text: 'between', hint: 'Matches the input that is inside the inclusive range.' },
  6. {
  7. text: 'consume',
  8. hint:
  9. 'The `consume` operator consumes the tabular data stream handed to it. It is\r\nmostly used for triggering the query side-effect without actually returning\r\nthe results back to the caller.',
  10. },
  11. { text: 'count', hint: 'Returns the number of records in the input record set.' },
  12. { text: 'datatable', hint: 'Returns a table whose schema and values are defined in the query itself.' },
  13. {
  14. text: 'distinct',
  15. hint: 'Produces a table with the distinct combination of the provided columns of the input table.',
  16. },
  17. { text: 'evaluate', hint: 'Invokes a service-side query extension (plugin).' },
  18. { text: 'extend', hint: 'Create calculated columns and append them to the result set.' },
  19. {
  20. text: 'externaldata',
  21. hint:
  22. 'Returns a table whose schema is defined in the query itself, and whose data is read from an external raw file.',
  23. },
  24. {
  25. text: 'facet',
  26. hint:
  27. 'Returns a set of tables, one for each specified column.\r\nEach table specifies the list of values taken by its column.\r\nAn additional table can be created by using the `with` clause.',
  28. },
  29. { text: 'find', hint: 'Finds rows that match a predicate across a set of tables.' },
  30. { text: 'fork', hint: 'Runs multiple consumer operators in parallel.' },
  31. { text: 'getschema', hint: 'Produce a table that represents a tabular schema of the input.' },
  32. { text: 'in', hint: 'Filters a recordset based on the provided set of values.' },
  33. { text: 'invoke', hint: 'Invokes lambda that receives the source of `invoke` as tabular parameter argument.' },
  34. {
  35. text: 'join',
  36. hint:
  37. 'Merge the rows of two tables to form a new table by matching values of the specified column(s) from each table.',
  38. },
  39. { text: 'limit', hint: 'Return up to the specified number of rows.' },
  40. { text: 'make-series', hint: 'Create series of specified aggregated values along specified axis.' },
  41. { text: 'mvexpand', hint: 'Expands multi-value array or property bag.' },
  42. { text: 'order', hint: 'Sort the rows of the input table into order by one or more columns.' },
  43. { text: 'parse', hint: 'Evaluates a string expression and parses its value into one or more calculated columns.' },
  44. {
  45. text: 'print',
  46. hint:
  47. 'Evaluates one or more scalar expressions and inserts the results (as a single-row table with as many columns as there are expressions) into the output.',
  48. },
  49. { text: 'project', hint: 'Select the columns to include, rename or drop, and insert new computed columns.' },
  50. { text: 'project-away', hint: 'Select what columns to exclude from the input.' },
  51. { text: 'project-rename', hint: 'Renames columns in the result output.' },
  52. { text: 'range', hint: 'Generates a single-column table of values.' },
  53. { text: 'reduce', hint: 'Groups a set of strings together based on values similarity.' },
  54. { text: 'render', hint: 'Instructs the user agent to render the results of the query in a particular way.' },
  55. { text: 'sample', hint: 'Returns up to the specified number of random rows from the input table.' },
  56. {
  57. text: 'sample-distinct',
  58. hint:
  59. 'Returns a single column that contains up to the specified number of distinct values of the requested column.',
  60. },
  61. { text: 'search', hint: 'The search operator provides a multi-table/multi-column search experience.' },
  62. { text: 'serialize', hint: 'Marks that order of the input row set is safe for window functions usage.' },
  63. { text: 'sort', hint: 'Sort the rows of the input table into order by one or more columns.' },
  64. { text: 'summarize', hint: 'Produces a table that aggregates the content of the input table.' },
  65. { text: 'take', hint: 'Return up to the specified number of rows.' },
  66. { text: 'top', hint: 'Returns the first *N* records sorted by the specified columns.' },
  67. {
  68. text: 'top-hitters',
  69. hint: 'Returns an approximation of the first *N* results (assuming skewed distribution of the input).',
  70. },
  71. {
  72. text: 'top-nested',
  73. hint: 'Produces hierarchical top results, where each level is a drill-down based on previous level values.',
  74. },
  75. { text: 'union', hint: 'Takes two or more tables and returns the rows of all of them.' },
  76. { text: 'where', hint: 'Filters a table to the subset of rows that satisfy a predicate.' },
  77. ];
  78. export const functionTokens = [
  79. { text: 'abs', hint: 'Calculates the absolute value of the input.' },
  80. {
  81. text: 'acos',
  82. hint:
  83. 'Returns the angle whose cosine is the specified number (the inverse operation of [`cos()`](cosfunction.md)) .',
  84. },
  85. { text: 'ago', hint: 'Subtracts the given timespan from the current UTC clock time.' },
  86. { text: 'any', hint: 'Returns random non-empty value from the specified expression values.' },
  87. {
  88. text: 'arg_max',
  89. hint:
  90. 'Finds a row in the group that maximizes *ExprToMaximize*, and returns the value of *ExprToReturn* (or `*` to return the entire row).',
  91. },
  92. {
  93. text: 'arg_min',
  94. hint:
  95. 'Finds a row in the group that minimizes *ExprToMinimize*, and returns the value of *ExprToReturn* (or `*` to return the entire row).',
  96. },
  97. {
  98. text: 'argmax',
  99. hint:
  100. 'Finds a row in the group that maximizes *ExprToMaximize*, and returns the value of *ExprToReturn* (or `*` to return the entire row).',
  101. },
  102. {
  103. text: 'argmin',
  104. hint:
  105. 'Finds a row in the group that minimizes *ExprToMinimize*, and returns the value of *ExprToReturn* (or `*` to return the entire row).',
  106. },
  107. { text: 'array_concat', hint: 'Concatenates a number of dynamic arrays to a single array.' },
  108. { text: 'array_length', hint: 'Calculates the number of elements in a dynamic array.' },
  109. { text: 'array_slice', hint: 'Extracts a slice of a dynamic array.' },
  110. {
  111. text: 'array_split',
  112. hint:
  113. 'Splits an array to multiple arrays according to the split indices and packs the generated array in a dynamic array.',
  114. },
  115. {
  116. text: 'asin',
  117. hint: 'Returns the angle whose sine is the specified number (the inverse operation of [`sin()`](sinfunction.md)) .',
  118. },
  119. {
  120. text: 'assert',
  121. hint: 'Checks for a condition; if the condition is false, outputs error messages and fails the query.',
  122. },
  123. {
  124. text: 'atan',
  125. hint:
  126. 'Returns the angle whose tangent is the specified number (the inverse operation of [`tan()`](tanfunction.md)) .',
  127. },
  128. {
  129. text: 'atan2',
  130. hint:
  131. 'Calculates the angle, in radians, between the positive x-axis and the ray from the origin to the point (y, x).',
  132. },
  133. { text: 'avg', hint: 'Calculates the average of *Expr* across the group.' },
  134. {
  135. text: 'avgif',
  136. hint:
  137. 'Calculates the [average](avg-aggfunction.md) of *Expr* across the group for which *Predicate* evaluates to `true`.',
  138. },
  139. { text: 'bag_keys', hint: 'Enumerates all the root keys in a dynamic property-bag object.' },
  140. { text: 'base64_decodestring', hint: 'Decodes a base64 string to a UTF-8 string' },
  141. { text: 'base64_encodestring', hint: 'Encodes a string as base64 string' },
  142. { text: 'beta_cdf', hint: 'Returns the standard cumulative beta distribution function.' },
  143. { text: 'beta_inv', hint: 'Returns the inverse of the beta cumulative probability beta density function.' },
  144. { text: 'beta_pdf', hint: 'Returns the probability density beta function.' },
  145. { text: 'bin', hint: 'Rounds values down to an integer multiple of a given bin size.' },
  146. {
  147. text: 'bin_at',
  148. hint:
  149. "Rounds values down to a fixed-size 'bin', with control over the bin's starting point.\r\n(See also [`bin function`](./binfunction.md).)",
  150. },
  151. {
  152. text: 'bin_auto',
  153. hint:
  154. "Rounds values down to a fixed-size 'bin', with control over the bin size and starting point provided by a query property.",
  155. },
  156. { text: 'binary_and', hint: 'Returns a result of the bitwise `and` operation between two values.' },
  157. { text: 'binary_not', hint: 'Returns a bitwise negation of the input value.' },
  158. { text: 'binary_or', hint: 'Returns a result of the bitwise `or` operation of the two values.' },
  159. { text: 'binary_shift_left', hint: 'Returns binary shift left operation on a pair of numbers.' },
  160. { text: 'binary_shift_right', hint: 'Returns binary shift right operation on a pair of numbers.' },
  161. { text: 'binary_xor', hint: 'Returns a result of the bitwise `xor` operation of the two values.' },
  162. { text: 'buildschema', hint: 'Returns the minimal schema that admits all values of *DynamicExpr*.' },
  163. {
  164. text: 'case',
  165. hint: 'Evaluates a list of predicates and returns the first result expression whose predicate is satisfied.',
  166. },
  167. {
  168. text: 'ceiling',
  169. hint: 'Calculates the smallest integer greater than, or equal to, the specified numeric expression.',
  170. },
  171. { text: 'cluster', hint: 'Changes the reference of the query to a remote cluster.' },
  172. {
  173. text: 'coalesce',
  174. hint: 'Evaluates a list of expressions and returns the first non-null (or non-empty for string) expression.',
  175. },
  176. { text: 'cos', hint: 'Returns the cosine function.' },
  177. { text: 'cot', hint: 'Calculates the trigonometric cotangent of the specified angle, in radians.' },
  178. {
  179. text: 'count',
  180. hint:
  181. 'Returns a count of the records per summarization group (or in total if summarization is done without grouping).',
  182. },
  183. { text: 'countif', hint: 'Returns a count of rows for which *Predicate* evaluates to `true`.' },
  184. {
  185. text: 'countof',
  186. hint: 'Counts occurrences of a substring in a string. Plain string matches may overlap; regex matches do not.',
  187. },
  188. { text: 'current_principal', hint: 'Returns the current principal running this query.' },
  189. {
  190. text: 'cursor_after',
  191. hint: 'A predicate over the records of a table to compare their ingestion time\r\nagainst a database cursor.',
  192. },
  193. {
  194. text: 'cursor_before_or_at',
  195. hint: 'A predicate over the records of a table to compare their ingestion time\r\nagainst a database cursor.',
  196. },
  197. { text: 'database', hint: 'Changes the reference of the query to a specific database within the cluster scope.' },
  198. {
  199. text: 'datetime_add',
  200. hint:
  201. 'Calculates a new [datetime](./scalar-data-types/datetime.md) from a specified datepart multiplied by a specified amount, added to a specified [datetime](./scalar-data-types/datetime.md).',
  202. },
  203. {
  204. text: 'datetime_diff',
  205. hint: 'Calculates calendarian difference between two [datetime](./scalar-data-types/datetime.md) values.',
  206. },
  207. { text: 'datetime_part', hint: 'Extracts the requested date part as an integer value.' },
  208. { text: 'dayofmonth', hint: 'Returns the integer number representing the day number of the given month' },
  209. { text: 'dayofweek', hint: 'Returns the integer number of days since the preceding Sunday, as a `timespan`.' },
  210. { text: 'dayofyear', hint: 'Returns the integer number represents the day number of the given year.' },
  211. { text: 'dcount', hint: 'Returns an estimate of the number of distinct values of *Expr* in the group.' },
  212. {
  213. text: 'dcount_hll',
  214. hint:
  215. 'Calculates the dcount from hll results (which was generated by [hll](hll-aggfunction.md) or [hll_merge](hll-merge-aggfunction.md)).',
  216. },
  217. {
  218. text: 'dcountif',
  219. hint:
  220. 'Returns an estimate of the number of distinct values of *Expr* of rows for which *Predicate* evaluates to `true`.',
  221. },
  222. {
  223. text: 'degrees',
  224. hint:
  225. 'Converts angle value in radians into value in degrees, using formula `degrees = (180 / PI ) * angle_in_radians`',
  226. },
  227. { text: 'distance', hint: 'Returns the distance between two points in meters.' },
  228. { text: 'endofday', hint: 'Returns the end of the day containing the date, shifted by an offset, if provided.' },
  229. { text: 'endofmonth', hint: 'Returns the end of the month containing the date, shifted by an offset, if provided.' },
  230. { text: 'endofweek', hint: 'Returns the end of the week containing the date, shifted by an offset, if provided.' },
  231. { text: 'endofyear', hint: 'Returns the end of the year containing the date, shifted by an offset, if provided.' },
  232. {
  233. text: 'estimate_data_size',
  234. hint: 'Returns an estimated data size of the selected columns of the tabular expression.',
  235. },
  236. { text: 'exp', hint: 'The base-e exponential function of x, which is e raised to the power x: e^x.' },
  237. {
  238. text: 'exp10',
  239. hint: 'The base-10 exponential function of x, which is 10 raised to the power x: 10^x. \r\n**Syntax**',
  240. },
  241. { text: 'exp2', hint: 'The base-2 exponential function of x, which is 2 raised to the power x: 2^x.' },
  242. {
  243. text: 'extent_id',
  244. hint: 'Returns a unique identifier that identifies the data shard ("extent") that the current record resides in.',
  245. },
  246. {
  247. text: 'extent_tags',
  248. hint:
  249. 'Returns a dynamic array with the [tags](../management/extents-overview.md#extent-tagging) of the data shard ("extent") that the current record resides in.',
  250. },
  251. { text: 'extract', hint: 'Get a match for a [regular expression](./re2.md) from a text string.' },
  252. { text: 'extract_all', hint: 'Get all matches for a [regular expression](./re2.md) from a text string.' },
  253. { text: 'extractjson', hint: 'Get a specified element out of a JSON text using a path expression.' },
  254. { text: 'floor', hint: 'An alias for [`bin()`](binfunction.md).' },
  255. { text: 'format_datetime', hint: 'Formats a datetime parameter based on the format pattern parameter.' },
  256. { text: 'format_timespan', hint: 'Formats a timespan parameter based on the format pattern parameter.' },
  257. { text: 'gamma', hint: 'Computes [gamma function](https://en.wikipedia.org/wiki/Gamma_function)' },
  258. { text: 'getmonth', hint: 'Get the month number (1-12) from a datetime.' },
  259. { text: 'gettype', hint: 'Returns the runtime type of its single argument.' },
  260. { text: 'getyear', hint: 'Returns the year part of the `datetime` argument.' },
  261. { text: 'hash', hint: 'Returns a hash value for the input value.' },
  262. { text: 'hash_sha256', hint: 'Returns a sha256 hash value for the input value.' },
  263. { text: 'hll', hint: 'Calculates the Intermediate results of [dcount](dcount-aggfunction.md) across the group.' },
  264. {
  265. text: 'hll_merge',
  266. hint: 'Merges hll results (scalar version of the aggregate version [`hll_merge()`](hll-merge-aggfunction.md)).',
  267. },
  268. { text: 'hourofday', hint: 'Returns the integer number representing the hour number of the given date' },
  269. {
  270. text: 'iff',
  271. hint:
  272. 'Evaluates the first argument (the predicate), and returns the value of either the second or third arguments, depending on whether the predicate evaluated to `true` (second) or `false` (third).',
  273. },
  274. {
  275. text: 'iif',
  276. hint:
  277. 'Evaluates the first argument (the predicate), and returns the value of either the second or third arguments, depending on whether the predicate evaluated to `true` (second) or `false` (third).',
  278. },
  279. {
  280. text: 'indexof',
  281. hint: 'Function reports the zero-based index of the first occurrence of a specified string within input string.',
  282. },
  283. { text: 'ingestion_time', hint: "Retrieves the record's `$IngestionTime` hidden `datetime` column, or null." },
  284. {
  285. text: 'iscolumnexists',
  286. hint:
  287. 'Returns a boolean value indicating if the given string argument exists in the schema produced by the preceding tabular operator.',
  288. },
  289. { text: 'isempty', hint: 'Returns `true` if the argument is an empty string or is null.' },
  290. { text: 'isfinite', hint: 'Returns whether input is a finite value (is neither infinite nor NaN).' },
  291. { text: 'isinf', hint: 'Returns whether input is an infinite (positive or negative) value.' },
  292. { text: 'isnan', hint: 'Returns whether input is Not-a-Number (NaN) value.' },
  293. { text: 'isnotempty', hint: 'Returns `true` if the argument is not an empty string nor it is a null.' },
  294. { text: 'isnotnull', hint: 'Returns `true` if the argument is not null.' },
  295. {
  296. text: 'isnull',
  297. hint:
  298. 'Evaluates its sole argument and returns a `bool` value indicating if the argument evaluates to a null value.',
  299. },
  300. { text: 'log', hint: 'Returns the natural logarithm function.' },
  301. { text: 'log10', hint: 'Returns the common (base-10) logarithm function.' },
  302. { text: 'log2', hint: 'Returns the base-2 logarithm function.' },
  303. {
  304. text: 'loggamma',
  305. hint: 'Computes log of absolute value of the [gamma function](https://en.wikipedia.org/wiki/Gamma_function)',
  306. },
  307. {
  308. text: 'make_datetime',
  309. hint: 'Creates a [datetime](./scalar-data-types/datetime.md) scalar value from the specified date and time.',
  310. },
  311. {
  312. text: 'make_dictionary',
  313. hint: 'Returns a `dynamic` (JSON) property-bag (dictionary) of all the values of *Expr* in the group.',
  314. },
  315. { text: 'make_string', hint: 'Returns the string generated by the Unicode characters.' },
  316. {
  317. text: 'make_timespan',
  318. hint: 'Creates a [timespan](./scalar-data-types/timespan.md) scalar value from the specified time period.',
  319. },
  320. { text: 'makelist', hint: 'Returns a `dynamic` (JSON) array of all the values of *Expr* in the group.' },
  321. {
  322. text: 'makeset',
  323. hint: 'Returns a `dynamic` (JSON) array of the set of distinct values that *Expr* takes in the group.',
  324. },
  325. {
  326. text: 'materialize',
  327. hint:
  328. 'Allows caching a sub-query result during the time of query execution in a way that other subqueries can reference the partial result.',
  329. },
  330. { text: 'max', hint: 'Returns the maximum value across the group.' },
  331. { text: 'max_of', hint: 'Returns the maximum value of several evaluated numeric expressions.' },
  332. {
  333. text: 'merge_tdigests',
  334. hint:
  335. 'Merges tdigest results (scalar version of the aggregate version [`merge_tdigests()`](merge-tdigests-aggfunction.md)).',
  336. },
  337. { text: 'min', hint: 'Returns the minimum value agross the group.' },
  338. { text: 'min_of', hint: 'Returns the minimum value of several evaluated numeric expressions.' },
  339. { text: 'monthofyear', hint: 'Returns the integer number represents the month number of the given year.' },
  340. {
  341. text: 'next',
  342. hint:
  343. 'Returns the value of a column in a row that it at some offset following the\r\ncurrent row in a [serialized row set](./windowsfunctions.md#serialized-row-set).',
  344. },
  345. { text: 'not', hint: 'Reverses the value of its `bool` argument.' },
  346. {
  347. text: 'now',
  348. hint:
  349. 'Returns the current UTC clock time, optionally offset by a given timespan.\r\nThis function can be used multiple times in a statement and the clock time being referenced will be the same for all instances.',
  350. },
  351. { text: 'pack', hint: 'Creates a `dynamic` object (property bag) from a list of names and values.' },
  352. {
  353. text: 'pack_all',
  354. hint: 'Creates a `dynamic` object (property bag) from all the columns of the tabular expression.',
  355. },
  356. { text: 'pack_array', hint: 'Packs all input values into a dynamic array.' },
  357. { text: 'parse_ipv4', hint: 'Converts input to integer (signed 64-bit) number representation.' },
  358. {
  359. text: 'parse_json',
  360. hint:
  361. 'Interprets a `string` as a [JSON value](https://json.org/)) and returns the value as [`dynamic`](./scalar-data-types/dynamic.md). \r\nIt is superior to using [extractjson() function](./extractjsonfunction.md)\r\nwhen you need to extract more than one element of a JSON compound object.',
  362. },
  363. {
  364. text: 'parse_path',
  365. hint:
  366. 'Parses a file path `string` and returns a [`dynamic`](./scalar-data-types/dynamic.md) object that contains the following parts of the path: \r\nScheme, RootPath, DirectoryPath, DirectoryName, FileName, Extension, AlternateDataStreamName.\r\nIn addition to the simple paths with both types of slashes, supports paths with schemas (e.g. "file://..."), shared paths (e.g. "\\\\shareddrive\\users..."), long paths (e.g "\\\\?\\C:...""), alternate data streams (e.g. "file1.exe:file2.exe")',
  367. },
  368. {
  369. text: 'parse_url',
  370. hint:
  371. 'Parses an absolute URL `string` and returns a [`dynamic`](./scalar-data-types/dynamic.md) object contains all parts of the URL (Scheme, Host, Port, Path, Username, Password, Query Parameters, Fragment).',
  372. },
  373. {
  374. text: 'parse_urlquery',
  375. hint:
  376. 'Parses a url query `string` and returns a [`dynamic`](./scalar-data-types/dynamic.md) object contains the Query parameters.',
  377. },
  378. {
  379. text: 'parse_user_agent',
  380. hint:
  381. "Interprets a user-agent string, which identifies the user's browser and provides certain system details to servers hosting the websites the user visits. The result is returned as [`dynamic`](./scalar-data-types/dynamic.md).",
  382. },
  383. { text: 'parse_version', hint: 'Converts input string representation of version to a comparable decimal number.' },
  384. {
  385. text: 'parse_xml',
  386. hint:
  387. 'Interprets a `string` as a XML value, converts the value to a [JSON value](https://json.org/) and returns the value as [`dynamic`](./scalar-data-types/dynamic.md).',
  388. },
  389. {
  390. text: 'percentile',
  391. hint:
  392. 'Returns an estimate for the specified [nearest-rank percentile](#nearest-rank-percentile) of the population defined by *Expr*. \r\nThe accuracy depends on the density of population in the region of the percentile.',
  393. },
  394. {
  395. text: 'percentile_tdigest',
  396. hint:
  397. 'Calculates the percentile result from tdigest results (which was generated by [tdigest](tdigest-aggfunction.md) or [merge-tdigests](merge-tdigests-aggfunction.md))',
  398. },
  399. {
  400. text: 'percentrank_tdigest',
  401. hint:
  402. "Calculates the approximate rank of the value in a set where rank is expressed as percentage of set's size. \r\nThis function can be viewed as the inverse of the percentile.",
  403. },
  404. { text: 'pi', hint: 'Returns the constant value of Pi (π).' },
  405. { text: 'point', hint: 'Returns a dynamic array representation of a point.' },
  406. { text: 'pow', hint: 'Returns a result of raising to power' },
  407. {
  408. text: 'prev',
  409. hint:
  410. 'Returns the value of a column in a row that it at some offset prior to the\r\ncurrent row in a [serialized row set](./windowsfunctions.md#serialized-row-set).',
  411. },
  412. {
  413. text: 'radians',
  414. hint:
  415. 'Converts angle value in degrees into value in radians, using formula `radians = (PI / 180 ) * angle_in_degrees`',
  416. },
  417. { text: 'rand', hint: 'Returns a random number.' },
  418. { text: 'range', hint: 'Generates a dynamic array holding a series of equally-spaced values.' },
  419. { text: 'repeat', hint: 'Generates a dynamic array holding a series of equal values.' },
  420. { text: 'replace', hint: 'Replace all regex matches with another string.' },
  421. { text: 'reverse', hint: 'Function makes reverse of input string.' },
  422. { text: 'round', hint: 'Returns the rounded source to the specified precision.' },
  423. {
  424. text: 'row_cumsum',
  425. hint:
  426. 'Calculates the cumulative sum of a column in a [serialized row set](./windowsfunctions.md#serialized-row-set).',
  427. },
  428. {
  429. text: 'row_number',
  430. hint:
  431. "Returns the current row's index in a [serialized row set](./windowsfunctions.md#serialized-row-set).\r\nThe row index starts by default at `1` for the first row, and is incremented by `1` for each additional row.\r\nOptionally, the row index can start at a different value than `1`.\r\nAdditionally, the row index may be reset according to some provided predicate.",
  432. },
  433. { text: 'series_add', hint: 'Calculates the element-wise addition of two numeric series inputs.' },
  434. { text: 'series_decompose', hint: 'Applies a decomposition transformation on a series.' },
  435. {
  436. text: 'series_decompose_anomalies',
  437. hint:
  438. 'Anomaly Detection based on series decomposition (refer to [series_decompose()](series-decomposefunction.md))',
  439. },
  440. { text: 'series_decompose_forecast', hint: 'Forecast based on series decomposition.' },
  441. { text: 'series_divide', hint: 'Calculates the element-wise division of two numeric series inputs.' },
  442. {
  443. text: 'series_equals',
  444. hint: 'Calculates the element-wise equals (`==`) logic operation of two numeric series inputs.',
  445. },
  446. { text: 'series_fill_backward', hint: 'Performs backward fill interpolation of missing values in a series.' },
  447. { text: 'series_fill_const', hint: 'Replaces missing values in a series with a specified constant value.' },
  448. { text: 'series_fill_forward', hint: 'Performs forward fill interpolation of missing values in a series.' },
  449. { text: 'series_fill_linear', hint: 'Performs linear interpolation of missing values in a series.' },
  450. { text: 'series_fir', hint: 'Applies a Finite Impulse Response filter on a series.' },
  451. {
  452. text: 'series_fit_2lines',
  453. hint: 'Applies two segments linear regression on a series, returning multiple columns.',
  454. },
  455. {
  456. text: 'series_fit_2lines_dynamic',
  457. hint: 'Applies two segments linear regression on a series, returning dynamic object.',
  458. },
  459. { text: 'series_fit_line', hint: 'Applies linear regression on a series, returning multiple columns.' },
  460. { text: 'series_fit_line_dynamic', hint: 'Applies linear regression on a series, returning dynamic object.' },
  461. {
  462. text: 'series_greater',
  463. hint: 'Calculates the element-wise greater (`>`) logic operation of two numeric series inputs.',
  464. },
  465. {
  466. text: 'series_greater_equals',
  467. hint: 'Calculates the element-wise greater or equals (`>=`) logic operation of two numeric series inputs.',
  468. },
  469. { text: 'series_iir', hint: 'Applies a Infinite Impulse Response filter on a series.' },
  470. { text: 'series_less', hint: 'Calculates the element-wise less (`<`) logic operation of two numeric series inputs.' },
  471. {
  472. text: 'series_less_equals',
  473. hint: 'Calculates the element-wise less or equal (`<=`) logic operation of two numeric series inputs.',
  474. },
  475. { text: 'series_multiply', hint: 'Calculates the element-wise multiplication of two numeric series inputs.' },
  476. {
  477. text: 'series_not_equals',
  478. hint: 'Calculates the element-wise not equals (`!=`) logic operation of two numeric series inputs.',
  479. },
  480. { text: 'series_outliers', hint: 'Scores anomaly points in a series.' },
  481. { text: 'series_periods_detect', hint: 'Finds the most significant periods that exist in a time series.' },
  482. {
  483. text: 'series_periods_validate',
  484. hint: 'Checks whether a time series contains periodic patterns of given lengths.',
  485. },
  486. {
  487. text: 'series_seasonal',
  488. hint: 'Calculates the seasonal component of a series according to the detected or given seasonal period.',
  489. },
  490. { text: 'series_stats', hint: 'Returns statistics for a series in multiple columns.' },
  491. { text: 'series_stats_dynamic', hint: 'Returns statistics for a series in dynamic object.' },
  492. { text: 'series_subtract', hint: 'Calculates the element-wise subtraction of two numeric series inputs.' },
  493. { text: 'sign', hint: 'Sign of a numeric expression' },
  494. { text: 'sin', hint: 'Returns the sine function.' },
  495. {
  496. text: 'split',
  497. hint:
  498. 'Splits a given string according to a given delimiter and returns a string array with the contained substrings.',
  499. },
  500. { text: 'sqrt', hint: 'Returns the square root function.' },
  501. { text: 'startofday', hint: 'Returns the start of the day containing the date, shifted by an offset, if provided.' },
  502. {
  503. text: 'startofmonth',
  504. hint: 'Returns the start of the month containing the date, shifted by an offset, if provided.',
  505. },
  506. {
  507. text: 'startofweek',
  508. hint: 'Returns the start of the week containing the date, shifted by an offset, if provided.',
  509. },
  510. {
  511. text: 'startofyear',
  512. hint: 'Returns the start of the year containing the date, shifted by an offset, if provided.',
  513. },
  514. {
  515. text: 'stdev',
  516. hint:
  517. 'Calculates the standard deviation of *Expr* across the group, considering the group as a [sample](https://en.wikipedia.org/wiki/Sample_%28statistics%29).',
  518. },
  519. {
  520. text: 'stdevif',
  521. hint:
  522. 'Calculates the [stdev](stdev-aggfunction.md) of *Expr* across the group for which *Predicate* evaluates to `true`.',
  523. },
  524. {
  525. text: 'stdevp',
  526. hint:
  527. 'Calculates the standard deviation of *Expr* across the group, considering the group as a [population](https://en.wikipedia.org/wiki/Statistical_population).',
  528. },
  529. { text: 'strcat', hint: 'Concatenates between 1 and 64 arguments.' },
  530. { text: 'strcat_array', hint: 'Creates a concatenated string of array values using specified delimiter.' },
  531. {
  532. text: 'strcat_delim',
  533. hint: 'Concatenates between 2 and 64 arguments, with delimiter, provided as first argument.',
  534. },
  535. { text: 'strcmp', hint: 'Compares two strings.' },
  536. { text: 'string_size', hint: 'Returns the size, in bytes, of the input string.' },
  537. { text: 'strlen', hint: 'Returns the length, in characters, of the input string.' },
  538. { text: 'strrep', hint: 'Repeats given [string](./scalar-data-types/string.md) provided amount of times.' },
  539. {
  540. text: 'substring',
  541. hint: 'Extracts a substring from a source string starting from some index to the end of the string.',
  542. },
  543. { text: 'sum', hint: 'Calculates the sum of *Expr* across the group.' },
  544. { text: 'sumif', hint: 'Returns a sum of *Expr* for which *Predicate* evaluates to `true`.' },
  545. { text: 'table', hint: 'References specific table using an query-time evaluated string-expression.' },
  546. { text: 'tan', hint: 'Returns the tangent function.' },
  547. {
  548. text: 'tdigest',
  549. hint: 'Calculates the Intermediate results of [`percentiles()`](percentiles-aggfunction.md) across the group.',
  550. },
  551. {
  552. text: 'tdigest_merge',
  553. hint:
  554. 'Merges tdigest results (scalar version of the aggregate version [`tdigest_merge()`](tdigest-merge-aggfunction.md)).',
  555. },
  556. { text: 'tobool', hint: 'Converts input to boolean (signed 8-bit) representation.' },
  557. { text: 'todatetime', hint: 'Converts input to [datetime](./scalar-data-types/datetime.md) scalar.' },
  558. { text: 'todecimal', hint: 'Converts input to decimal number representation.' },
  559. {
  560. text: 'todouble',
  561. hint: 'Converts the input to a value of type `real`. (`todouble()` and `toreal()` are synonyms.)',
  562. },
  563. {
  564. text: 'todynamic',
  565. hint:
  566. 'Interprets a `string` as a [JSON value](https://json.org/) and returns the value as [`dynamic`](./scalar-data-types/dynamic.md).',
  567. },
  568. { text: 'toguid', hint: 'Converts input to [`guid`](./scalar-data-types/guid.md) representation.' },
  569. { text: 'tohex', hint: 'Converts input to a hexadecimal string.' },
  570. { text: 'toint', hint: 'Converts input to integer (signed 32-bit) number representation.' },
  571. { text: 'tolong', hint: 'Converts input to long (signed 64-bit) number representation.' },
  572. { text: 'tolower', hint: 'Converts input string to lower case.' },
  573. { text: 'toscalar', hint: 'Returns a scalar constant value of the evaluated expression.' },
  574. { text: 'tostring', hint: 'Converts input to a string representation.' },
  575. { text: 'totimespan', hint: 'Converts input to [timespan](./scalar-data-types/timespan.md) scalar.' },
  576. { text: 'toupper', hint: 'Converts a string to upper case.' },
  577. {
  578. text: 'translate',
  579. hint:
  580. "Replaces a set of characters ('searchList') with another set of characters ('replacementList') in a given a string.\r\nThe function searches for characters in the 'searchList' and replaces them with the corresponding characters in 'replacementList'",
  581. },
  582. { text: 'treepath', hint: 'Enumerates all the path expressions that identify leaves in a dynamic object.' },
  583. { text: 'trim', hint: 'Removes all leading and trailing matches of the specified regular expression.' },
  584. { text: 'trim_end', hint: 'Removes trailing match of the specified regular expression.' },
  585. { text: 'trim_start', hint: 'Removes leading match of the specified regular expression.' },
  586. { text: 'url_decode', hint: 'The function converts encoded URL into a to regular URL representation.' },
  587. {
  588. text: 'url_encode',
  589. hint: 'The function converts characters of the input URL into a format that can be transmitted over the Internet.',
  590. },
  591. {
  592. text: 'variance',
  593. hint:
  594. 'Calculates the variance of *Expr* across the group, considering the group as a [sample](https://en.wikipedia.org/wiki/Sample_%28statistics%29).',
  595. },
  596. {
  597. text: 'varianceif',
  598. hint:
  599. 'Calculates the [variance](variance-aggfunction.md) of *Expr* across the group for which *Predicate* evaluates to `true`.',
  600. },
  601. {
  602. text: 'variancep',
  603. hint:
  604. 'Calculates the variance of *Expr* across the group, considering the group as a [population](https://en.wikipedia.org/wiki/Statistical_population).',
  605. },
  606. { text: 'weekofyear', hint: 'Returns the integer number represents the week number.' },
  607. {
  608. text: 'welch_test',
  609. hint: 'Computes the p_value of the [Welch-test function](https://en.wikipedia.org/wiki/Welch%27s_t-test)',
  610. },
  611. {
  612. text: 'zip',
  613. hint:
  614. 'The `zip` function accepts any number of `dynamic` arrays, and returns an\r\narray whose elements are each an array holding the elements of the input\r\narrays of the same index.',
  615. },
  616. ];
  617. export const KEYWORDS = [
  618. 'by',
  619. 'on',
  620. 'contains',
  621. 'notcontains',
  622. 'containscs',
  623. 'notcontainscs',
  624. 'startswith',
  625. 'has',
  626. 'matches',
  627. 'regex',
  628. 'true',
  629. 'false',
  630. 'and',
  631. 'or',
  632. 'typeof',
  633. 'int',
  634. 'string',
  635. 'date',
  636. 'datetime',
  637. 'time',
  638. 'long',
  639. 'real',
  640. '​boolean',
  641. 'bool',
  642. ];
  643. export const grafanaMacros = [
  644. {
  645. text: '$__timeFilter',
  646. display: '$__timeFilter()',
  647. hint: 'Macro that uses the selected timerange in Grafana to filter the query.',
  648. },
  649. {
  650. text: '$__escapeMulti',
  651. display: '$__escapeMulti()',
  652. hint: 'Macro to escape multi-value template variables that contain illegal characters.',
  653. },
  654. { text: '$__contains', display: '$__contains()', hint: 'Macro for multi-value template variables.' },
  655. ];
  656. // Kusto operators
  657. // export const OPERATORS = ['+', '-', '*', '/', '>', '<', '==', '<>', '<=', '>=', '~', '!~'];
  658. export const DURATION = ['SECONDS', 'MINUTES', 'HOURS', 'DAYS', 'WEEKS', 'MONTHS', 'YEARS'];
  659. const tokenizer = {
  660. comment: {
  661. pattern: /(^|[^\\:])\/\/.*/,
  662. lookbehind: true,
  663. greedy: true,
  664. },
  665. 'function-context': {
  666. pattern: /[a-z0-9_]+\([^)]*\)?/i,
  667. inside: {},
  668. },
  669. duration: {
  670. pattern: new RegExp(`${DURATION.join('?|')}?`, 'i'),
  671. alias: 'number',
  672. },
  673. builtin: new RegExp(`\\b(?:${functionTokens.map(f => f.text).join('|')})(?=\\s*\\()`, 'i'),
  674. string: {
  675. pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
  676. greedy: true,
  677. },
  678. keyword: new RegExp(`\\b(?:${KEYWORDS.join('|')}|${operatorTokens.map(f => f.text).join('|')}|\\*)\\b`, 'i'),
  679. boolean: /\b(?:true|false)\b/,
  680. number: /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
  681. operator: /-|\+|\*|\/|>|<|==|<=?|>=?|<>|!~|~|=|\|/,
  682. punctuation: /[{};(),.:]/,
  683. variable: /(\[\[(.+?)\]\])|(\$(.+?))\b/,
  684. };
  685. tokenizer['function-context'].inside = {
  686. argument: {
  687. pattern: /[a-z0-9_]+(?=:)/i,
  688. alias: 'symbol',
  689. },
  690. duration: tokenizer.duration,
  691. number: tokenizer.number,
  692. builtin: tokenizer.builtin,
  693. string: tokenizer.string,
  694. variable: tokenizer.variable,
  695. };
  696. // console.log(tokenizer.builtin);
  697. export default tokenizer;
  698. // function escapeRegExp(str: string): string {
  699. // return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
  700. // }