Skip to content

Instantly share code, notes, and snippets.

@tecmaverick
Last active March 15, 2022 15:40
Show Gist options
  • Save tecmaverick/6cd76ae18ee576b1c59789d0838bf9ef to your computer and use it in GitHub Desktop.
Save tecmaverick/6cd76ae18ee576b1c59789d0838bf9ef to your computer and use it in GitHub Desktop.
Decoding Redshift SQL Error
Redshift outputs the following error, when SQL syntax error is encountered.
ERROR: syntax error at or near "," Position: 937
In error message, position 937 denotes the character where the error is identified. To locate this,
remove line feed from the SQL statement.
Removing line feeds via Visual Studio Code.
Paste the SQL statement, and open Find and Replace
MAC: Option + Command + F
Windows: Ctrl + H
In find textbox, provide $\n and blank in replace textbox. Choose "Use regular expression" option, and hit "Replace All".
Removing line feeds via bash.
Paste SQL query to file and excute the command
Mac (result available in clipboard):
cat SQLFilename.txt | tr -d "\n" | tr -d "\r" | pbcopy
Linux (Copy the output from terminal):
cat SQLFilename.txt | tr -d "\n" | tr -d "\r"
=============================================================================
Error: "Invalid operation: Specified types or functions (one per INFO message) not supported on Redshift tables."
Meaning: The query contains references to leader node table\functions from compute node.
Sample occurance: Calling 'generate_series' or 'now()' function and joining with tables from compute node. (Applicable for multi-node clusters)
=============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment