Common log query and analysis errors
This article describes common errors in log query and analysis and their solutions.
Query and analysis errors
-
If you have an issue with a query and analysis statement, use Copilot to troubleshoot. You can also use SQL optimization. For more information, see Use AI to generate query and analysis statements (Copilot).
On the query and analysis page of the Log Service console, an SQL query to find the daily top 10 client IP addresses by access volume returns Log entries: 0, and the timeline chart displays no data points. Copilot then automatically intervenes, provides diagnostic suggestions, and corrects the query statement. The corrected query then returns the correct analysis result. This animation demonstrates the complete troubleshooting flow with Copilot.
-
Log Service also supports intelligent query through the Agent Skill feature. For more information, see Use SLS Query Skill for intelligent log query and analysis.
Logstore does not exist
Logstore lacks index configuration
Too many queued queries
-
Error description
This error occurs when the number of concurrent queries in your Project exceeds the quota.
-
Explanation
The SQL concurrency quota in Log Service is isolated at the Project level. When you submit SQL requests within a Project, each running query consumes a quota slot, which is released after the query completes. The SQL concurrency quota for a Project is 15 for queries in normal SQL mode and 100 for queries in enhanced SQL mode.
-
Causes
-
The number of concurrent requests is too high.
-
Individual SQL queries have high execution latency.
-
Your application's retry logic causes excessive retries after a request fails.
-
-
Solution
-
Reduce the number of concurrent requests.
-
Optimize your SQL queries to reduce execution latency.
-
Implement retry logic with a random wait time. This helps prevent repeated, inefficient retries that increase the concurrent request load.
-
Duplicate column conflicts
-
Error description
An alias for an index field in the Logstore you are querying is causing a conflict. As a result, SQL cannot determine which column to analyze.
-
Cause
A column name in the Logstore is exactly the same as the alias of another column.
-
Solution
Check the index key columns of the target Logstore for naming conflicts.
Denied by STS or RAM, action:*
-
Error description
You do not have the required permission to query the logstore.
-
Cause
Your current identity does not have the required permissions for the logstore.
-
Solution
Check your RAM permissions and grant the
log:GetLogStoreLogspermission to your current identity. The authorization policy must include the following action and resource:action: log:GetLogStoreLogs, resource: acs:log:<region>:<uid>:project/<project>/logstore/<logstore>
FROM clause required in nested subqueries
-
Error description
When using nested subqueries in SQL, you must specify the table name in the innermost subquery.
-
Explanation
To simplify single-table queries, Simple Log Service uses the current logstore as the default table. For example, if your current logstore is named
test, the following three queries are equivalent:-
Query 1: You can omit the FROM clause.
-
Query 2: You can use
FROM log, which specifies the current logstore. -
Query 3: You can explicitly specify the logstore by name, such as
FROM test.
However, when running complex queries with subqueries, Simple Log Service cannot infer the target table for each subquery. Therefore, you must manually specify the FROM clause in each one.
-
-
Solution
-
To query the current logstore, use
FROM log. -
Alternatively, specify the target logstore by name.
-
In clause type mismatch
-
Error description
This error indicates that the value and list items in an IN clause must have the same data type.
-
Cause
This error is caused by a data type mismatch between the value and the list items in the IN operator. For example, the value is a varchar, while the list items are integers.
-
Solution
To resolve this, ensure that the value and list items in the IN operator share the same data type. You can use the CAST or CONVERT function to convert the values to a matching data type before running the query. As a best practice, use the same data type for the corresponding column when writing logs to prevent similar errors.
Unexpected parameters (bigint) for function url_decode. Expected: url_decode(varchar(x))
-
Problem
This error occurs when you pass a parameter of the wrong data type to an SQL function.
-
Cause
-
The function expects a string parameter, but you provided a bigint parameter.
-
This type of error can occur with different functions, such as url_decode or regexp_like. The cause is always a mismatch between the data type the function expects and the one you provide.
-
-
Solution
To resolve this issue, convert the input parameter to a string before passing it to the url_decode function. You can use the
CASTorCONVERTfunction to convert the bigint parameter to a string. If the parameter is a literal, enclose it in quotation marks to treat it as a string. For example:SELECT url_decode(CAST(bigint_param AS varchar(20))) -- Use CAST to convert a bigint parameter to a string. SELECT url_decode('123456789') -- If the parameter is a literal, enclose it in quotation marks to treat it as a string.
Target of repeat operator is not specified
-
Error description
The target of the repeat operator is not specified.
-
Cause
The regular expression engine throws this error when a repeat operator in your regular expression is missing a target. Repeat operators, such as
*,+, or?, must apply to a preceding character or group. For example, in the valid expression(a)*, the*operator applies to the group(a). However, in invalid patterns like*aor()*, the operator has no target, so the engine does not know what to repeat. -
Solution
Review your regular expression to ensure that every repeat operator immediately follows a valid character or group. Correct the pattern by providing a target or removing the misplaced operator.
Null values not allowed on semi-join probe side
-
Error description
NULL values are not allowed on the probe side of a semi join.
-
Cause
This error occurs because a row in the probe table or a value from a subquery returned a NULL value, which prevents the semi join from executing correctly.
-
Solution
Check the query plan to identify which table returns a NULL value. If a subquery is involved, ensure that its result set does not contain NULL values. If an external table is the source of the NULL values, consider replacing the semi join with an INNER JOIN or using the COALESCE or ISNULL functions to handle them.
Array subscript out of bounds
-
Error description
Array subscript out of bounds.
-
Cause
You attempted to access an index outside the valid range of the array, for example, a negative index or an index that exceeds the array length. This issue is typically caused by incorrect logic in your SQL statement or invalid input data.
-
Solution
In SQL, array indexes start at 1. Check the array length in your SQL statement, and ensure that each index you reference is within the valid range.
Expression "*" is not of type ROW
-
Error description
The expression 'fields' is not a ROW type.
-
Cause
This error indicates that the 'fields' expression is not a valid ROW type. This can occur if you pass invalid parameters to the ROW function.
-
Solution
Check the parameters of the ROW function to ensure all specified fields exist and are valid. If the parameters are correct but the expression is still not a ROW type, use the CAST function to convert it to a ROW type.
Key-value delimiter must appear once
-
Error description
The key-value delimiter must appear exactly once in each entry.
-
Cause
The system cannot parse a key-value pair if its delimiter appears more than once or is missing.
-
Solution
Check your input to ensure each key-value pair uses exactly one delimiter to separate the key from the value.
Pattern has # groups. Cannot access group
-
Error description
The regular expression cannot access the specified group.
-
Cause
The regular expression matched 0 groups, making it impossible to access a specific group. This happens if you use grouping syntax in a regular expression without defining any capturing groups.
-
Solution
Check the grouping syntax in your regular expression and ensure that at least one capturing group is defined in the pattern. You can use parentheses
()to define a capturing group. For example, to match an email address in a string and capture the username and domain name as separate groups, use the regular expression(\w+)@(\w+\.\w+). This pattern creates two groups. You can then access their matched values by referencinggroup(1)andgroup(2). If you need to group parts of a pattern without capturing the matched text, use a non-capturing group, such as(?:\w+)@(?:\w+\.\w+). If the issue persists, use an online regex checker to debug and validate the pattern before adding it to your SQL query.
Invalid group by type for ts_compare
-
The
ts_comparefunction requires agroup byclause on a column of thetimestamptype. -
This error occurs when you use the
ts_comparefunction in an SQL query, but the column in thegroup byclause is not of thetimestamptype, such as a numeric type. -
Ensure the column in the
group byclause is of thetimestamptype when using thets_comparefunction. For example, use thefrom_unixtimefunction to convert an integer timestamp to thetimestamptype.
Out of range timestamp
-
Error description
The timestamp is outside the specified time range.
-
Cause
The SQL statement contains an out-of-range timestamp, possibly due to data entry errors or a data type mismatch.
-
Solution
Verify that the timestamp is correct. If a data type mismatch is the cause, use a data type conversion function to cast the timestamp to the correct data type.
Unsupported ROW comparison with NULL elements
-
Error description
ROW comparison is not supported for fields that contain NULL elements.
-
Cause
Your SQL statement uses a comparison operator, such as
=or!=, on a ROW-type field that contains a NULL element. In SQL, any comparison involving a NULL value evaluates to UNKNOWN, which causes the operation to fail. -
Solution
Before performing a row comparison, you must handle NULL elements in the ROW-type field. You can filter them out using operators like
IS NULLorIS NOT NULL, or replace them with a default value using theCOALESCEfunction. As a best practice, handle NULL values earlier in your data pipeline, such as during data ingestion or processing, to prevent this error.
The specified key does not exist
-
Description
This error occurs during a foreign table join query when a specified object key does not exist in the target OSS bucket.
-
Cause
The specified object does not exist in the OSS bucket. This can happen if the object was deleted, never existed, or if you provided an incorrect bucket endpoint or object key.
-
Solutions
-
Verify the OSS bucket name and object key.
-
Use the OSS console to confirm that the object key exists in the bucket.
-
Paginated query exceeds row limit
-
Description
The maximum number of rows for a paginated query is 1,000,000.
-
Cause
Simple Log Service SQL limits the number of output rows to 1,000,000. This error occurs because your request exceeds this limit.
-
Solutions
-
Use the LIMIT clause to restrict the query to 1,000,000 rows or fewer.
-
Narrow the query range to return 1,000,000 rows or fewer.
-
Use the Scheduled SQL service to perform periodic SQL aggregation analysis in windows. Then, perform a secondary aggregation on the results.
-
Could not choose a best candidate operator. Explicit type casts must be added.
-
Error description
Could not choose the best candidate operator. Explicit type casts must be added.
-
Cause
This error usually occurs when you perform an arithmetic or comparison operation on variables of different data types, and the system cannot automatically determine which operator to use.
-
Solution
Add an explicit type cast to specify which operator to use.
For example, to add a string and an integer, use the CAST function to convert the string to an integer before the addition:
SELECT CAST('10' AS INTEGER) + 5;In this example, the CAST function prevents the error by converting the string '10' to an integer before adding it to 5.
Function * not registered
-
Error description
The specified function does not exist.
-
Causes
The specified function is not found in SLS SQL. This error occurs if:
-
You use a function specific to a database vendor that is not supported by SLS SQL.
-
You misspell the function name.
-
-
Solution
Verify that the function name is spelled correctly and is supported by SLS SQL.
SQL array indices start at 1
Index must be greater than zero
COALESCE operands must be the same type
-
Description
All operands in the COALESCE function must have the same data type.
-
Cause
The operands in the COALESCE function have mismatched data types. This error occurs when a boolean type is used with another data type, such as a number or string.
-
Solution
Check the data type of each operand in the COALESCE function. If a mismatch is found, use the CAST function to convert the operands to a common data type.
Subquery returns multiple columns
Group by clause cannot contain aggregate or window functions
-
Error description
The
GROUP BYclause cannot containaggregate functionsorwindow functions. -
Cause
This error occurs when you include an
aggregate functionor awindow functionin theGROUP BYclause. -
Solution
Ensure the
GROUP BYclause contains onlycolumn names.Aggregate functionsandwindow functionsbelong in theSELECT statement, not theGROUP BYclause. To group by the result of an aggregation, use itsaliasornumeric indexin theGROUP BYclause, not the function expression itself. For example:SELECT column1, column2, COUNT(column3) as count_column3 FROM table GROUP BY column1, column2, 3In this query,
count_column3is thealiasforCOUNT(column3), and3is thenumeric indexthat refers to its position in theSELECT statement. Note that using anumeric indexcan make code harder to read and maintain. Using analiasis recommended for clarity.
WHERE clause function restrictions
-
Error description
A
WHEREclause cannot contain aggregate functions or window functions. -
Cause
This error occurs because the
WHEREclause is evaluated before groups and aggregates are calculated. Therefore, the results from an aggregate or window function are not yet available for filtering. -
Solution
Use the
WHEREclause to filter individual rows based on column values. To filter grouped data based on the result of an aggregate function, use theHAVINGclause. TheHAVINGclause runs after data grouping and aggregation.For example, use the following query:
SELECT column1, column2, COUNT(column3) AS count_column3 FROM table GROUP BY column1, column2 HAVING count_column3 > 10In this query,
count_column3is the alias for the result of theCOUNT(column3)aggregate function. TheHAVINGclause correctly filters the grouped results based on this alias.
Left side of LIKE expression must evaluate to a varchar (actual: bigint)
-
Error description
The left operand of a LIKE expression must be a varchar, but a bigint was provided.
-
Cause
The LIKE operator performs pattern matching on string data types. This error occurs because an attempt was made to apply it to a non-string data type (bigint).
-
Solution
Use the CAST function to convert the bigint to a varchar.
SELECT * FROM table WHERE CAST(bigint_column AS varchar) LIKE 'pattern'This statement first converts the bigint_column to a varchar, which enables the LIKE operator to perform a pattern match against the specified pattern.
Left side of logical expression must be boolean
-
Error description
The left side of the logical expression must be a boolean type (actual: varchar).
-
Cause
This error usually occurs when you try to use a logical expression where the right side of a relational operator, such as
=or!=, is a boolean value (true or false), but the type on the left side is a non-boolean type, such as varchar or another type. -
Solution
Ensure the left side of the logical expression is a boolean type.
Logical expression: boolean expected
Invalid json_path: ...
-
error description
The specified json_path is invalid.
-
cause
This error occurs if you use a JSON function, such as
json_extract,json_extract_scalar, orjson_size, with an invalid json_path in an SQL statement. -
solution
-
A json_path is normally specified in the format
$.a.b. In this format,$represents the root node of the current JSON object, and the period.is used to reference a nested node. However, if a field name in the JSON object contains special characters (such as., a space , or-), for example, http.path, http path, or http-path, you need to use square brackets[]instead of a period.and enclose the field name in double quotes"". For example:* | SELECT json_extract_scalar(request, '$["X-Power-Open-App-Id"]') -
For more information, see JSON functions and FAQs about the query and analysis of JSON logs.
-
Limit exceeded for distinct operations
Key not present in map
-
Error description
The specified key does not exist in the map.
-
Cause
This error occurs when a query attempts to access a key that does not exist in a map type column.
-
Solution
-
Verify that the specified key exists in the map data.
-
To prevent a query from failing when a key might not exist, wrap the map access expression with the
try function. This function returnsNULLif the key is not found. For example:SELECT try(map['name']) -- Returns NULL if the 'name' key is not found.
-
Column 'XXX' cannot be resolved
-
Cause
No index is configured for the XXX field.
-
Solution
Create an index for the field and enable analytics. For more information, see Create indexes.
Query parse error: Syntax error
-
Cause
The query statement has a syntax error near the colon
:. -
Solution
Correct and rerun the query statement.
Column 'XXX' not in GROUP BY clause
-
Cause
In an SQL statement, if you use a GROUP BY clause, any column in the SELECT statement must either be included in the GROUP BY clause or be used in an aggregation. For example,
* | SELECT status, request_time, COUNT(*) AS PV GROUP BY statusis an invalid analysis statement because the request_time column is not aggregated or included in the GROUP BY clause. -
Solution
Modify and rerun the query statement. For example, the corrected statement is
* | SELECT status, arbitrary(request_time), COUNT(*) AS PV GROUP BY status. For more information, see GROUP BY clause.
Missing query statement
-
Cause
This error occurs when an analysis statement is used by itself. In Simple Log Service, an analysis statement must be preceded by a query statement. The required format is
query statement | analysis statement. -
Solution
Add a query statement before the analysis statement. For example,
* | SELECT status, count(*) AS PV GROUP BY status. For more information, see basic syntax.
line 1:10: identifiers must not start with a digit; surround the identifier with double quotes
-
Cause
This error indicates that an identifier, such as a column name or a variable name, starts with a digit. The SQL standard requires identifiers to start with a letter and consist only of letters, digits, and underscores (_).
-
Solution
Change the alias. For more information, see Column aliases.
line 1:9: extraneous input ‘’ expecting
-
Cause
The statement contains extraneous Chinese quotation marks.
-
Solution
Correct the query and analysis statements, then re-execute them.
Key not configured for key-value search
-
Cause
A field index has not been created for the target field, or the target field contains special characters (such as spaces) and is not enclosed in double quotation marks ("").
-
Solution
-
Verify that a field index has been created for the target field and the log analysis feature is enabled.
-
If so, continue to the next step.
-
If not, create a field index for the target field and enable the log analysis feature. For more information, see Create indexes.
If this resolves the issue, no further steps are required.
-
-
Enclose the target field in double quotation marks ("").
-
Query memory limit exceeded
-
Cause
A query statement can exceed the 3 GB server-side memory limit if its GROUP BY clause produces an excessive number of unique values.
-
Solution
Optimize the GROUP BY clause by reducing the number of fields it contains.
Error: Column 'XXX' cannot be resolved
-
Cause
This error occurs because XXX, which is not an
indexed field, is enclosed in double quotation marks (""). In ananalysis statement, astringmust be enclosed in single quotation marks (''). Ananalysis statementtreats unquoted text or text enclosed in double quotation marks ("") as afield nameorcolumn name. -
Solution
-
If you want to analyze XXX as a field, configure an
indexfor it and enable thelog analysis feature. For more information, see Create indexes. -
If XXX is a
string, enclose it in single quotation marks ('').
-
Concurrent analysis operation limit
-
Cause
Log Service allows a maximum of 15 concurrent analysis operations per Project. This limit has been exceeded.
-
Solution
Reduce your concurrent analysis operations to 15 or fewer.
Unclosed string quote
-
Cause
The query and analysis statement contains unmatched double quotes (").
-
Solution
Correct the query and analysis statement and run it again.
Error after :.error detail:error after :.error detail:line 1:147: mismatched input 'in' expecting {<EOF>, 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'OR', 'AND', 'UNION', 'EXCEPT', 'INTERSECT'}
-
Cause
The query statement contains the invalid keyword
in. -
Solution
Correct the query statement and run it again.
Duplicate keys (XXX) are not allowed
-
cause
A duplicate index was configured for a field.
-
solution
Check your index configuration. For more information, see Create indexes.
Unsupported wildcard position in a query
-
Cause
This error occurs when a wildcard character is placed in an unsupported position in a fuzzy search.
-
Solution
Modify the wildcards in the query according to the following rules:
-
You can use an asterisk (
*) or a question mark (?) as a wildcard character in the middle or at the end of a word. -
You cannot use an asterisk (
*) or a question mark (?) at the beginning of a word. -
You cannot use an asterisk (
*) or a question mark (?) to perform a fuzzy search on fields of thelongordoubledata type.
-
Logstore XXX not found
-
Cause
The Logstore XXX does not exist or does not have indexes configured.
-
Solution
Verify that the Logstore exists. Ensure that at least one field index is configured and the log analysis feature is enabled.
Field limit exceeded
-
Cause
Your search statement contains 43 fields, which exceeds the Log Service limit of 30.
-
Solution
Modify the search statement to use 30 or fewer fields.
ErrorType:SyntaxError.ErrorPosition,line:1,column:19.ErrorMessage:line 1:19: Expression "data" is not of type ROW
-
Cause
The query statement uses a field with an invalid data type.
-
Solution
Verify that the parameters of the
ROWfunction are correct and that all fields within those parameters exist and meet requirements. If the parameters are correct but the result is not theROWtype, use theCASTfunction to convert the result to theROWtype.
ErrorType:SyntaxError.ErrorPosition,line:1,column:9.ErrorMessage:line 1:9: identifiers must not contain ':'
-
Cause
The field name contains a colon (:).
-
Solution
Enclose the field in double quotation marks (""). For example, to analyze the
__tag__:__receive_time__field, use the statement*| select "__tag__:__receive_time__".ImportantBefore you analyze a field, you must create an index for it. For more information, see Manually create a field index.
No nodes available to run query
-
Cause
This is an internal system error.
-
Solution
Refresh the page and rerun the query and analysis statement.