使用pythonu执行:
exchange_path = f"dfs://market/{exchange.value}"
script = f'''if(existsDatabase(\"{exchange_path}\")) {{ dropDatabase(\"{exchange_path}\") }}'''
session.run(script)
出错提示:
RuntimeError: <Server Exception> in run: dropDatabase("dfs://market/BINANCE") => deleteSubChunks failed on '/market/BINANCE', chunk 17a19f25-cc16-15ae-714b-5ee30d5d6795 is not in COMPLETE state
请把这些分区先用dropPartiontion强制删除,然后再用dropDatabase删除数据库。示例代码如下:
dbName=exchange_path
fileCond=dbName + "%" t=exec substr(file,strlen(dbName)) from rpc(getControllerAlias(),getClusterChunksStatus) where file like fileCond, state != "COMPLETE" dropPartition(database("dfs:/"+dbName),t,,true)