我用列数据类型- [Comments] [varchar](2000) NULL创建了Synapse表
当我使用Databricks火花代码写入Synapse时,我看到Synapse表列的数据类型更改为[Comments] [nvarchar](256) NULL。在Databricks dataframe上,数据类型为string。
数据库星火代码-
df.write \
.format("com.databricks.spark.sqldw") \
.option("url", "jdbc:sqlserver://<>") \
.option("user", "myuser") \
.option("password", "***") \
.option("forwardSparkAzureStorageCredentials", "true") \
.option("dbTable", table_name) \
.option("tempDir", "wasbs://<container>@<storageAccount>.blob.core.windows.net/<path>) \
.mode("overwrite") \
.save()发布于 2022-07-19 09:25:51
我可以在代码中添加以下选项:
.option("maxStrLength", 2000)或者,如果您确信列名和数据类型不会随着时间的推移而更改,我将手动删除并创建包含所需类型的表,然后将模式更改为“追加”,然后添加预操作以截断表:
.option("preActions", "truncate table "+table_name) \
.mode("append") \https://stackoverflow.com/questions/73025078
复制相似问题