使用JDBC使用JDBC的DataBricks数据框架使用varchar(255)创建字符串列,而字符串值大于255。如何解决此问题?
我使用以下Python命令将数据框写入Oracle DB和MS SQL DB。此数据框具有来自值生成的模式,其中包括数据类型的字符串类型字段/列。其中一些值非常大,例如尺寸为750或更高。
以下一个到MS SQL将字符串类型字段默认为VARCHAR(MAX)创建,因此没有问题。
usersDF.write \
.format("jdbc") \
.option("url", conn)\
.option("user", sqlUserName)\
.option("password", dbPassword)\
.option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver")\
.option("dbTable", "DBS_Processed_Users") \
.mode('overwrite')\
.save()
而尝试反对Oracle DB时,则将字符串类型字段作为Varchar(255)创建。
usersDF.write \
.format("jdbc") \
.option("url", oraConn)\
.option("user", oraUserName)\
.option("password", oraPassword)\
.option("driver", "oracle.jdbc.driver.OracleDriver")\
.option("dbTable", "Schema.DBS_Processed_Users") \
.mode('overwrite')\
.save()
确保将写入Oracle以Max或1000为精度创建Oracle的最佳方法是什么?我什至可以创建表,但是模式=覆盖,以某种方式将其覆盖为255并导致数据写故障。
这个问题或任何解决方案有更好的建议吗?
I am using below python command to write the dataframe to Oracle Db and MS SQL Db. This dataframe has schema generated out of the values, and that includes string type fields/columns by datatype. Some of the values are very larger like around size of 750 or above.
The below one to MS SQL creates the string type fields as varchar(max) by default and hence no issues.
usersDF.write \
.format("jdbc") \
.option("url", conn)\
.option("user", sqlUserName)\
.option("password", dbPassword)\
.option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver")\
.option("dbTable", "DBS_Processed_Users") \
.mode('overwrite')\
.save()
Whereas, the same when attempted against Oracle db, creates the string type fields as varchar(255) by default.
usersDF.write \
.format("jdbc") \
.option("url", oraConn)\
.option("user", oraUserName)\
.option("password", oraPassword)\
.option("driver", "oracle.jdbc.driver.OracleDriver")\
.option("dbTable", "Schema.DBS_Processed_Users") \
.mode('overwrite')\
.save()
What's the best way to ensure that the write to Oracle gets created with max or 1000 as precision? I can even create the table but the mode=overwrite, somehow overwrites it to 255 and causing the data write failures.
Is there any better recommendations to this problem or any solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论