-
Notifications
You must be signed in to change notification settings - Fork 9.9k
[Log explorer] Adds new page for SQL queries #24005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+133 KB
(360%)
src/assets/images/log-explorer/supported-sql-grammar-graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| --- | ||
| pcx_content_type: concept | ||
| title: SQL queries supported | ||
| sidebar: | ||
| order: 3 | ||
| --- | ||
|
|
||
| This page outlines the SQL features supported by Log Explorer, including common aggregation functions, expressions, and query clauses. | ||
| The diagram below illustrates the general shape of a valid query supported in Log Explorer. It shows how standard SQL clauses—such as `SELECT`, `WHERE`, `GROUP BY`, and `ORDER BY` — can be composed to form supported queries. | ||
|
|
||
|  | ||
angelampcosta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Examples of queries include: | ||
|
|
||
| - `SELECT * FROM table WHERE (a = 1 OR b = "hello") AND c < 25.89` | ||
| - `SELECT a, b, c FROM table WHERE d >= "GB" LIMIT 10` | ||
|
|
||
| :::note | ||
| - A default `LIMIT` of 10,000 is applied if the `LIMIT` clause is omitted. | ||
| - The `WHERE` clause supports up to 25 predicates, which can be grouped using parentheses. | ||
| ::: | ||
|
|
||
| ### SQL Clauses in detail | ||
|
|
||
| The following SQL clauses define the structure and logic of queries in Log Explorer: | ||
|
|
||
| - `SELECT` - The `SELECT` clause specifies the columns that you want to retrieve from the database tables. It can include individual column names, expressions, or even wildcard characters to select all columns. | ||
| - `FROM` - The `FROM` clause specifies the tables from which to retrieve data. It indicates the source of the data for the `SELECT` statement. | ||
| - `WHERE` - The `WHERE` clause filters the rows returned by a query based on specified conditions. It allows you to specify conditions that must be met for a row to be included in the result set. | ||
| - `SELECT DISTINCT` - Removes duplicate rows from the result set. | ||
| - `GROUP BY` - Groups rows for aggregation. The `GROUP BY` clause is used to group rows that have the same values into summary rows. | ||
| - `ORDER BY` - Sorts the result set. The `ORDER BY` clause is used to sort the result set by one or more columns in ascending or descending order. | ||
| - `LIMIT` - Restricts the number of rows returned. The `LIMIT` clause is used to constrain the number of rows returned by a query. It is often used in conjunction with the `ORDER BY` clause to retrieve the top N rows or to implement pagination. | ||
| - `OFFSET` - Skips a specified number of rows before returning results. | ||
|
|
||
| The sections that follow break down the remaining components shown in the diagram — such as aggregation functions, string and numeric expressions, and supported operators — in more detail. | ||
|
|
||
| ## Functions | ||
| Log Explorer supports a range of SQL functions to transform, evaluate, or summarize data. These include scalar and aggregation functions. | ||
angelampcosta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Scalar functions | ||
|
|
||
| These help manipulate or evaluate values (often strings): | ||
angelampcosta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - `ARRAY_CONTAINS(array, element)` – Checks if the array contains the element. | ||
|
|
||
| Example: `ARRAY_CONTAINS(['US', 'CA'], ClientCountry)` | ||
|
|
||
| Returns rows where `ClientCountry` is either `US` or `CA`. | ||
|
|
||
| - `SUBSTRING(string, from_number, for_number)` – Extracts part of a string. | ||
|
|
||
| Example: `SUBSTRING(ClientRequestPath, 0, 5)` | ||
|
|
||
| Extracts the first `5` characters from `ClientRequestPath`. | ||
|
|
||
| - `LOWER(string)` – Converts to lowercase. | ||
|
|
||
| Example: `LOWER(ClientRequestUserAgent)` | ||
|
|
||
| Converts the user agent string to lowercase. | ||
|
|
||
| - `UPPER(string)` – Converts to uppercase. | ||
|
|
||
| Example: `UPPER(ClientCountry)` | ||
|
|
||
| Converts the country code to uppercase. | ||
|
|
||
| ### Aggregation functions | ||
|
|
||
| Used to perform calculations on sets of rows: | ||
|
|
||
| - `SUM(expression)` – Total of values. | ||
|
|
||
| Example: `SUM(ClientRequestBytes)` | ||
|
|
||
| Adds up the total number of bytes requested by clients. | ||
|
|
||
| - `MIN(expression)` – Minimum value. | ||
|
|
||
| Example: `MIN(OriginResponseDurationMs)` | ||
|
|
||
| Finds the shortest response time from origin servers. | ||
|
|
||
| - `MAX(expression)` – Maximum value. | ||
|
|
||
| Example: `MAX(OriginResponseDurationMs)` | ||
|
|
||
| Finds the longest response time. | ||
|
|
||
| - `COUNT(expression)` – Number of rows (can be all rows or non-null values). | ||
|
|
||
| Example: `COUNT(ClientRequestUserAgent)`` | ||
|
|
||
| Counts how many rows have a user agent value. | ||
|
|
||
| - `COUNT(DISTINCT expression)` – Number of distinct non-null values. | ||
|
|
||
| Example: `COUNT(DISTINCT ClientIP)` | ||
|
|
||
| Counts how many unique client IPs made requests. | ||
|
|
||
| - `AVG(expression)` – Average of numeric values. | ||
|
|
||
| Example: `AVG(OriginResponseDurationMs)` | ||
|
|
||
| Computes the average origin response time in milliseconds. | ||
|
|
||
| The diagram below represents the grammar for SQL expressions including scalar and aggregate functions. | ||
|
|
||
|  | ||
|
|
||
| ## Expressions | ||
|
|
||
| Conditions or logic used in queries: | ||
|
|
||
| - `CASE WHEN` – Conditional logic (like if-else). | ||
| - `AS` – Alias for columns or tables. | ||
| - `LIKE` – Pattern matching. | ||
| - `IN (list)` – Checks if a value is in a list. | ||
| - `BETWEEN ... AND ...` – Checks if a value is within a range. | ||
| - `Unary operator` – Operates on one operand (for example, `-5`). | ||
| - `Binary operator` – Operates on two operands (for example, `5 + 3`). | ||
| - `Nested Expressions` – Expression wrapped with parentheses, like `( x > y )` or `( 1 )`. | ||
| - `Compound identifier` – Multi-part name (for example, `schema.table.column`). | ||
| - `Array` – A collection of values (supported differently across SQL dialects). | ||
| - `Literals` - represent values such as strings, numbers, or arrays. | ||
|
|
||
| The diagram below represents the grammar for SQL expressions, detailing the various forms an expression can take, including columns, literals, functions, operators, and aliases. | ||
|
|
||
|  | ||
|
|
||
| The diagram below defines the grammar for unary operators, which operate on a single operand (for example, negation or logical NOT): | ||
|
|
||
|  | ||
|
|
||
| ## Binary Operators | ||
|
|
||
| Used for arithmetic, comparison, logical operations: | ||
|
|
||
| - Arithmetic: `+`, `-`, `*`, `/`, `%` (modulo) | ||
| - Comparison: `>`, `<`, `>=`, `<=`, `=`, `!=` (or `<>`)` | ||
| - Logical: `AND`, `OR`, `XOR` | ||
| - Bitwise: `&`, `|`, `^`, `>>`, `<<` | ||
| - String concat: `||` | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.