Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jdbc Azure DataRicks Scala Dataframe:将字符串类型列值插入SQLServer varbinary()类型列_Jdbc_Apache Spark Sql_Databricks_Jdbc Odbc - Fatal编程技术网

Jdbc Azure DataRicks Scala Dataframe:将字符串类型列值插入SQLServer varbinary()类型列

Jdbc Azure DataRicks Scala Dataframe:将字符串类型列值插入SQLServer varbinary()类型列,jdbc,apache-spark-sql,databricks,jdbc-odbc,Jdbc,Apache Spark Sql,Databricks,Jdbc Odbc,我有一个dataframe,它在其中一列中保存hashvalue。我使用sha2_512生成如下哈希值 sha2(concat_ws(" ", forHashColumnNameListBuffer.map(col): _*), 512) 当我试图使用JDBC连接将这个数据帧插入SQLServer中的表时,我得到了下面的错误 Job aborted due to stage failure: Task 0 in stage 8.0 failed 4 times, most

我有一个dataframe,它在其中一列中保存hashvalue。我使用sha2_512生成如下哈希值

sha2(concat_ws(" ", forHashColumnNameListBuffer.map(col): _*), 512)
当我试图使用JDBC连接将这个数据帧插入SQLServer中的表时,我得到了下面的错误

Job aborted due to stage failure: Task 0 in stage 8.0 failed 4 times, most recent failure: Lost task 0.3 in stage 8.0 (TID 20, 10.171.93.5, executor 1): java.sql.BatchUpdateException: Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.
这是因为dataframe中的Hashvalue列的类型为string,而目标列的数据类型为varbinary(64)

我尝试了以下两种方法来消除错误。但是没有用

  • 我尝试应用.cast(BinaryType),如下所示。但它正在改变实际价值

    sha2(concat_ws(“),forHashColumnNameListBuffer.map(col):*),512.cast(二进制类型)

  • 我尝试了.cast(二进制类型),如下所示。但dataframe中的最后一个列类型仍然是字符串

    sha2(concat_ws(“),forHashColumnNameListBuffer.map(col):*).cast(BinaryType),512)

  • 有没有办法解决这个问题

    提前谢谢