我认为我正在火花中发现一个错误,该错误不尊重模式“ overwrite”,而是试图将saveAsTable放入已经存在的表中(使用模式“ overwrite”)。
下面是一个重现问题的小脚本。最后一条语句导致堆栈跟踪读取:
private Handler broadcastReceiverHandler = null;
private HandlerThread broadcastReceiverThread = null;
private Looper broadcastReceiverThreadLooper = null;
private BroadcastReceiver broadcastReceiverReadScans = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
}
}
private void registerForIntents() {
broadcastReceiverThread = new HandlerThread("THREAD_NAME");//Create a thread for BroadcastReceiver
broadcastReceiverThread.start();
broadcastReceiverThreadLooper = broadcastReceiverThread.getLooper();
broadcastReceiverHandler = new Handler(broadcastReceiverThreadLooper);
IntentFilter filterScanReads = new IntentFilter();
filterScanReads.addAction("ACTION_SCAN_READ");
filterScanReads.addCategory("CATEGORY_SCAN");
context.registerReceiver(broadcastReceiverReadScans, filterScanReads, null, broadcastReceiverHandler);
}
private void unregisterIntents() {
context.unregisterReceiver(broadcastReceiverReadScans);
broadcastReceiverThreadLooper.quit();//Don't forget
}
任何建议,不胜感激。
org.apache.spark.sql.AnalysisException: Table `example` already exists.;
答案 0 :(得分:1)
saveAsTable
不检查其他选项,请直接使用mode
df3.write.mode(SaveMode.Overwrite).saveAsTable("example")
或
df3.write.mode("overwrite").saveAsTable("example")