SPARK SQL 中registerTempTable與saveAsTable的區別


使用registerTempTable注冊表是一個臨時表,生命周期只在所定義的sqlContext或hiveContext實例之中。換而言之,在一個sqlontext(或hiveContext)中registerTempTable的表不能在另一個sqlContext(或hiveContext)中使用。

而saveAsTable則是永久的,只要連接存在,spark再啟的時候,這個表還是在的。

官網上的描述:

Unlike theregisterTempTable command, saveAsTable will materialize the contents of the dataframe and create a pointer to the data in the HiveMetastore. Persistent tables will still exist even after your Spark program has restarted, as long as you maintain your connection to the same metastore. A DataFrame for a persistent table can be created by calling the table method on a SQLContext with the name of the table.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM