【发布时间】:2023-02-10 08:34:20
【问题描述】:
I'm new on databricks and spark, we create delta table using data from sql. Theese table are kind of mirrored. Basicalli if I insert a new row to sql it affects delta, I can even insert from databricks having sql updated, but deleting is allowed only from sql. By the way, I don't understand how it works, if I create a delta table with this command the delta and sql table are linked
spark.sql("""
create table IF NOT EXISTS dbname.delta_table
using org.apache.spark.sql.jdbc
OPTIONS (
url '""" + sql_url + """',
dbtable 'dbname.sql_table',
user '""" + sql_user + """',
password '""" + sql_password + """',
TRUNCATE true
)
""");
But if I try with pyspark, there's no link between table
spark.read \
.format("jdbc") \
.option("url", url_sql) \
.option("dbtable", sql_table) \
.option("user", sql_user) \
.option("password", sql_password) \
.option("truncate", True) \
.load() \
.write \
.saveAsTable(delta_table)
I would like to know how to get the same result with pyspark and how to get more documentation about it, I didn't find what I was looking for, I don't know what kind of relationship there's between table and the keyword related to this. Thanks for help Sergio
I've been looking online all day to find the correct topic but I didn't find anything
标签: sql-server apache-spark pyspark azure-databricks mssql-jdbc
delta_table. TheSQLandPySparkscripts are doing two different things. TheSQLone is creating a table in SQL Server (with no schema?) and thepysparkone is reading the same table from SQL Server and saving it as adeltatableUSING deltaor nothing at all. Can you point to the documentation where it tells you that you can create a delta table with that SQL command?