2017-12-18 381 views
0

我試圖用JDBCUtils截斷表從星火postgre_table,但它拋出下面的錯誤錯誤而使用PostgreTable JDBCUtils的truncateTable方法使用星火

< console>:71: error: value truncateTable is not a member of object org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils

val trucate_table = JdbcUtils.truncateTable()

我使用下面的代碼:

import org.apache.spark.sql.execution.datasources.jdbc._ 
import java.sql.DriverManager 
import java.sql.Connection 

val connection : Connection = DriverManager.getConnection(postgres_host + postgres_database,postgres_username,postgres_password) 

val table_existing = JdbcUtils.tableExists(connection, postgres_host + postgres_database, postgre_table) 
JdbcUtils.truncateTable(connection, postgres_host + postgres_database, postgre_table) 

我能夠刪除表,但不能截斷它。我可以在https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala中看到truncateTable方法

請提出解決方案以及如何在數據框中使用它。

回答