PostgreSQL语法错误在“$ 1”或附近

时间:2022-06-01 18:37:57
sql"""copy updateTable
from $path
credentials 'aws_access_key_id=<my_access_key_id>;aws_secret_access_key=<my_secret_access_key>'
json '<path_to_s3_repository>'
gzip;""".update().apply()

Above command gives

以上命令给出

org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"

when run on spark streaming using scala. What might be the issue? The resultant query runs fine when run from command line.

当使用scala在spark流上运行时。可能是什么问题?从命令行运行时生成的查询运行正常。

1 个解决方案

#1


1  

You cannot use a parameter with COPY.

您不能将参数与COPY一起使用。

You have to add the literal value of $path to the statement string and execute that.

您必须将$ path的文字值添加到语句字符串并执行它。

#1


1  

You cannot use a parameter with COPY.

您不能将参数与COPY一起使用。

You have to add the literal value of $path to the statement string and execute that.

您必须将$ path的文字值添加到语句字符串并执行它。