我正在尝试检查配置单元 Metastore 中是否存在表,如果不存在,则创建表。如果表存在,追加数据。
我有下面的代码片段:
spark.catalog.setCurrentDatabase("db_name")
db_catalog = spark.catalog.listTables(dbName = 'table_name)
if any(table_name in row for row in db_catalog):
add data
else:
create table
但是,我收到一个错误。
>>> ValueError: Some of types cannot be determined after inferring
我无法解决值错误,因为在 hive metastore 中创建的其他数据库表也出现相同的错误。还有另一种方法可以检查表是否存在于配置单元元存储中吗?
原文由 Cryssie 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以为此使用 JVM 对象。
用于 Python 功能的 Py4j 套接字。其他操作使用 JVM
SparkContext
。在 Spark Scala 中可以直接访问。