最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Calling SQL Server stored procedure via AWS EMR PySpark notebook with JDBC driver - Stack Overflow

programmeradmin1浏览0评论

I'm trying to load data from SQL Server from a stored procedure in PySpark using the JDBC driver.

Calling a stored procedure is supposed to be possible with this driver according to this

I'm tried the following code:

%%configure -f
{
    "conf": {
        "spark.jars": "s3://mv-prod-emr-scripts/jars/mssql-jdbc-12.8.1.jre8.jar"
    }
}

str_username = "<user>"
str_password = "<password>"

str_jdbc_warehouse_url = "jdbc:sqlserver://<IP>:1433;databaseName=<Database>"
str_warehouse_query = "call zzzTestProcedure"

df = spark.read \
          .format("jdbc") \
          .option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver") \
          .option("trustServerCertificate", "true") \
          .option("url", str_jdbc_warehouse_url) \
          .option("query", str_warehouse_query) \
          .option("user", str_username) \
          .option("password", str_password) \
          .load()

I can confirm that the JDBC driver and connections all work for a regular query, but I have a specific requirement that needs a stored procedure.

I've tried a variety of syntaxes for the SQL code and I consistently get syntax errors.

Query: "call zzzTestProcedure"
Error: "com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near ')'."

Query: "exec zzzTestProcedure"
Error: "com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the 
keyword 'exec'."

What's the correct syntax for calling a stored proc via the JDBC driver with PySpark?

发布评论

评论列表(0)

  1. 暂无评论