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

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

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744639466a4585352.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信