pyspark 调用o107.load时出错

olhwl3o2  于 2022-11-01  发布在  Spark
关注(0)|答案(1)|浏览(224)

我正在尝试使用以下代码连接到 Teradata

conf = SparkConf()
conf.set("spark.repl.local.jars", f"{jar_location}//terajdbc4.jar")
conf.set("spark.executor.extraClassPath", f"{jar_location}//terajdbc4.jar")
conf.set("spark.driver.extraClassPath", f"{jar_location}//terajdbc4.jar")

driver = 'com.teradata.jdbc.TeraDriver'
url = "jdbc:teradata://{0}".format(hostname)

spark = SparkSession.builder \
        .config(conf=conf) \
        .appName(appName) \
        .master(master) \
        .getOrCreate()

df = spark.read \
        .format('jdbc') \
        .option('driver', driver) \
        .option('url', url) \
        .option('query', "Select * from {0}.".format(database) + srcTable) \
        .option('user', username) \
        .option('password', password) \
        .load()
print(df)

我收到以下错误:

py4j.protocol.Py4JJavaError: An error occurred while calling o107.load.
: java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 17.10.00.27] 
[Error 1536] [SQLState HY000] 
Invalid connection parameter name url

此错误意味着什么?如何解决它?

pdtvr36n

pdtvr36n1#

@Fred是正确的。请执行以下操作:

url = "jdbc:teradata://{0}/STRICT_NAMES=OFF".format(hostname)

相关问题