Knowledge Base
Unsupported Type Error in NQL Queries
Overview
The "Unsupported Type Error" occurs when a Network Query Language (NQL) query includes data types or operations that are not supported by the narrative.io platform. This error typically arises during the processing or parsing of NQL queries. Understanding and resolving this error involves correcting the types or operations to align with supported formats.
Common Scenarios
- Geometry Type Not Supported:
- Error Title:
Unsupported Type Error: GEOMETRY
- Description: The NQL query involves the
GEOMETRY
type, which is unsupported in the SELECT by the current system.
Example:
{
"type": "https://www.narrative.io/knowledge-base/support-troubleshooting/nql/unsupported-type-error",
"title": "Unsupported Type Error: Unsupported GEOMETRY Type",
"status": 422,
"detail": "The NQL query includes the unsupported GEOMETRY type. The request cannot be processed because the GEOMETRY type is not supported in the SELECT.",
"instance": "/nql/run",
"logId": "2cf8fef9-9dc2-4438-b6f9-e28c386e48cc"
}
- Unsupported String Concatenation:
- Error Title:
Unsupported Type Error: String Concatenation
- Description: The query attempts to concatenate incompatible data types using the
||
operator.
Example:
{
"type": "https://www.narrative.io/knowledge-base/support-troubleshooting/nql/unsupported-type-error",
"title": "Unsupported Type Error: String Concatenation",
"status": 422,
"detail": "The NQL query encountered an unsupported type error when attempting to concatenate different types using the '||' operator. The '||' operator can only concatenate :string\[ || :string\[or \<EQUIVALENTTYPE> || \<EQUIVALENTTYPE> and is not compatible with '\<RECORDTYPE\:PEEKDEFAULT(VARCHAR TYPE, VARCHAR VALUE)> || \<CHAR(1)>'.",
"instance": "/nql/parse",
"logId": "7798e641-5d5e-47d3-a884-f5271e788b6b"
}
Troubleshooting Steps
Understanding the cause of the error and how to resolve it is crucial for troubleshooting:
- Identify the Error Type: Review the error message, particularly the
detail
field, to understand what type is not supported. - Analyze the Query: Inspect the NQL query to identify where the unsupported type is being applied.
- Refer to Supported Types: Verify the supported data types for the operations you are performing. Ensure all data types in your query are compatible with the expected types.
- Test the Modified Query: Rerun the query to ensure it executes successfully without errors.
Example Resolution
Scenario: Unsupported Geometry Type
- Review the Error Message: The NQL query includes the unsupported GEOMETRY type.
- Analyze the Query: Find the GEOMETRY type in the SELECT statement.
CREATE MATERIALIZED VIEW "location_maids" AS
WITH ObservationsInPois AS (
SELECT
"companydata"."1234"."mobileiduniqueidentifier"."value" AS maid,
"companydata"."1234"."eventtimestamp" AS eventtimestamp,
STCIRCLE("companydata"."11504"."Longitude", "companydata"."11504"."Latitude", 15) AS poiname,
"companydata"."11504"."eventtimestamp" AS poitimestamp,
"companydata"."11504"."ID" AS ID
FROM "companydata"."1234"
INNER JOIN "companydata"."11504"
ON STIntersects(
STSafePoint("companydata"."1234"."geographiclocation"."longitude", "companydata"."1234"."geographiclocation"."latitude"),
STCIRCLE("companydata"."11504"."Longitude", "companydata"."11504"."Latitude", 15)
)
WHERE "companydata"."1234"."eventtimestamp"
BETWEEN "companydata"."11504"."eventtimestamp" - INTERVAL '4' MINUTE
AND "companydata"."11504"."eventtimestamp" + INTERVAL '4' MINUTE
),
MaidsThatDwelled AS (
SELECT maid, poiname
FROM ObservationsInPois
GROUP BY maid, poiname
HAVING EXTRACT(EPOCH FROM MAX(eventtimestamp)) - EXTRACT(EPOCH FROM MIN(eventtimestamp)) > 30
)
SELECT ObservationsInPois.maid, ObservationsInPois.eventtimestamp, ObservationsInPois.poiname, ObservationsInPois.poitimestamp, ObservationsInPois.ID
FROM ObservationsInPois
JOIN MaidsThatDwelled
ON MaidsThatDwelled.poiname = ObservationsInPois.poiname AND MaidsThatDwelled.maid = ObservationsInPois.maid;
- Modify the Query: Replace the GEOMETRY type in the SELECT statement with a supported type or restructure the query to avoid using GEOMETRY.
- Test the Query: Execute the revised query to confirm it works correctly.
Scenario: Unsupported String Concatenation
- Review the Error Message: Read the error detail:
Cannot apply '||' to arguments of type '<RECORDTYPE:PEEK_DEFAULT(VARCHAR TYPE, VARCHAR VALUE)> || <CHAR(1)>'.
- Analyze the Query: Find the concatenation operation in the query.
- NQL Query:
EXPLAIN SELECT
"iso31661country",
"nio"."metadata"."source" AS "ProviderJSON",
COUNT(DISTINCT "uniquecombination") AS "TotaalCombinationsCount"
FROM (
SELECT
"iso31661country",
"nio"."metadata"."source",
"hashedemail" || '-' || "mobileiduniqueidentifier" || '-' || "eventtimestamp" AS "uniquecombination"
FROM "companydata"."1234"
) AS subquery
GROUP BY
"iso31661country",
"ProviderJSON";
- Modify the Query: Ensure all operands of the
||
operator are strings. Convert the data to supported types if necessary. - Test the Query: Rerun the query to ensure it executes without encountering type errors.