这个 SparkSession.catalog
对象具有一系列与元存储交互的方法,即:
['cacheTable',
'clearCache',
'createExternalTable',
'createTable',
'currentDatabase',
'dropGlobalTempView',
'dropTempView',
'isCached',
'listColumns',
'listDatabases',
'listFunctions',
'listTables',
'recoverPartitions',
'refreshByPath',
'refreshTable',
'registerFunction',
'setCurrentDatabase',
'uncacheTable']
不幸的是,似乎没有程序化的方法来删除表。
有多种方法可以实现这一点
spark.sql(f"drop table my_table")
或
spark._jsparkSession.sharedState().externalCatalog().dropTable(db, table, True, True)
但与一个简单的,尽管缺失的, dropTable
方法?
有更好的办法吗?
1条答案
按热度按时间k75qkfdt1#
以上提到的方法都是最常用的方法。我没有别的感觉。。
但从这些文件中我可以看到另一种方式。。。
你可以试试这个
org.apache.spark.sql.hive.HiveUtils
有好吃的东西给你。我对python不太在行,您可以看到下面的scala示例,并遵循python的相同方法。
打电话的人会说