IntelliJ - redshift - run sql from file - "create temporary table as" ignored/stripped when executing sql
I have configured a Redshift datasource using the driver com.amazon.redshift.jdbc42.Driver. I can execute most SQL from a .sql file just fine, and I can execute SQL that creates a temp table directly in the DB console, but if I try to execute SQL that creates a temp table from a .sql file, the "create temporary table as" portion of the command is stripped or ignored.
When I execute the SQL below directly in the DB console, all of the statements are shown in the console as expected, and there are no errors selecting from the newly created temp table. If I execute the exact same SQL from within a .sql file (selecting snippet and executing via Cmd+Enter [on Mac] or running the entire file), the "DROP TABLE IF EXISTS tmpMyTable" statement is shown, the "SELECT DISTINCT..." statement is shown (without the "CREATE TEMPORARY TABLE..." portion), and then there's an error saying tmpMyTable doesn't exist. It makes sense that the table wouldn't exist if the "CREATE TEMPORARY TABLE..." is being stripped/ignored as indicated by the difference in the console output.
Please advise. Thanks, James
DROP TABLE IF EXISTS tmpMyTable;
CREATE TEMPORARY TABLE tmpMyTable
AS SELECT DISTINCT user_id
FROM mySchema.myUserTable
WHERE user_id IN (6, 7, 8) '3121','3122','3123','3124','3129','3130','3131','3132','3133','3135','3136','3137','3138','3139','3140','3141','3142','3146','3147','3148')
;
SELECT * FROM tmpMyTable;
Please sign in to leave a comment.
In the shown sql script there seems to be a syntax error. Do you run the exact same script?
Please make sure to set RedShift dialect for the script. Also please make sure that the file is executed against correct data source and the schema:
As it seems working for me.
Pleas also try 2018.1.5 EAP from https://confluence.jetbrains.com/display/IDEADEV/IDEA+2018.1+EAP Related issue have been fixed there: https://youtrack.jetbrains.com/issue/DBE-6358.
Setting the dialect for SQL files fixed the issue for me. Thanks!