S02002
Error Code
S02002
Error Message
Failed to parse the metacode of SQL statement into distributed queries.
RefId:S02002
Probable Causes
If the metacode of SQL statements involves distributed query, it will first check whether the query can be split into multiple subqueries for each partition. Queries below may throw an error:
-
Queries that need a final unified operation after executing subqueries, such as a TOP N operation, may need to fetch a larger number of rows from each partition, and then perform a final TOP N merge.
SELECT EventTime FROM pt ORDER BY EventTime LIMIE 10;
-
Queries whose results depend on the data order, like calculating the difference between two adjacent elements (function deltas).
SELECT deltas(x) FROM pt;
-
Queries contain joins between different data sources like in-memory and partitioned tables.
SELECT SUM(x) FROM t1 LEFT JOIN pt2 ON t1.id = pt2.id
-
Queries with PIVOT BY clause.
SELECT x FROM PIVOTE BY timestamp, sym;
Solutions
Check whether the query can be split into multiple subqueries. If not, consider replacing the SQL metacode with a SQL statement. For example:
n = 10000
type = take(1..10, n)
t = table(type)
dbName = "dfs://test_db";
db = database(dbName, HASH, [INT, 2])
pt = db.createPartitionedTable(t, `pt, `type)
pt.append!(t)
saveText(<select top 100 * from pt>, "res.txt") // throw an exception
saveText(select top 100 * from pt, "res.txt") // successfully executed