I have a query (actual query is obv larger and more complex) like:
INSERT INTO my_table
WITH a (SELECT timestamp, count FROM foo),
b (SELECT timestamp, count FROM bar),
c (
SELECT * FROM foo
UNION ALL
SELECT * FROM bar
)
SELECT timestamp, count FROM c;
SELECT timestamp, SUM(count) FROM my_table;
This works fine. However when I change it because I'm investigating the query results to:
WITH a (SELECT timestamp, count FROM foo),
b (SELECT timestamp, count FROM bar),
c (
SELECT * FROM foo
UNION ALL
SELECT * FROM bar
)
SELECT timestamp, SUM(count)
FROM c
GROUP BY 1;
It throws a Not Implemented error with code 1001. Now this is 100% a RedShift bug because it seems to not be able to track the types across my query, but my actual question is all I can see in STL_ERROR
is:
file,linenum,context,error
../src/sys/pg_utils.cpp,2218,Not implemented,'value' - Ill formed PARAM_EXEC in expression
../src/sys/pg_utils.cpp,2218,Not implemented,'value' - Ill formed PARAM_EXEC in expression
In STV_RECENT
it doesn't even appear. How can I break down what RedShift is doing to track down the point where it's failing exactly? The only change to my original query is attempting to do a ... SUM ... GROUP 1
on the original query causing it to fail.
timestamp is a reserved word so it might be having trouble trying to associate the position alias of "1" with the reserved word "timestamp". Try using double quotes around the column name and/or explicitly using the column name in the group by rather than the position alias.