-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-5821] [SQL] JSON CTAS command should throw error message when delete path failure #4610
Changes from 5 commits
5a42d83
e4bc229
79f7040
e2df8d5
46f0d9d
42d7fb6
c387fce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,9 +66,21 @@ private[sql] class DefaultSource | |
mode match { | ||
case SaveMode.Append => | ||
sys.error(s"Append mode is not supported by ${this.getClass.getCanonicalName}") | ||
case SaveMode.Overwrite => | ||
fs.delete(filesystemPath, true) | ||
case SaveMode.Overwrite => { | ||
try { | ||
if (!fs.delete(filesystemPath, true)) { | ||
throw new IOException( | ||
s"Unable to clear output directory ${filesystemPath.toString} prior" | ||
+ s" to INSERT OVERWRITE a JSON table:\n") | ||
} | ||
} catch { | ||
case e: IOException => | ||
throw new IOException( | ||
s"Unable to clear output directory ${filesystemPath.toString} prior" | ||
+ s" to INSERT OVERWRITE a JSON table:\n${e.toString}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Save here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also catch the one thrown by |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yanbohappy Seems we just throw another error message at here. Based on your JIRA description, I think you need to check if delete returns true or false when data already exists. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yhuai Yes, it is expected. If there is no exception thrown, it can ensure delete success. I have investigated other codes in spark and they do the same thing for delete. |
||
true | ||
} | ||
case SaveMode.ErrorIfExists => | ||
sys.error(s"path $path already exists.") | ||
case SaveMode.Ignore => false | ||
|
@@ -110,7 +122,11 @@ private[sql] case class JSONRelation( | |
|
||
if (overwrite) { | ||
try { | ||
fs.delete(filesystemPath, true) | ||
if (fs.exists(filesystemPath) && !fs.delete(filesystemPath, true)) { | ||
throw new IOException( | ||
s"Unable to clear output directory ${filesystemPath.toString} prior" | ||
+ s" to INSERT OVERWRITE a JSON table:\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get rid of |
||
} | ||
} catch { | ||
case e: IOException => | ||
throw new IOException( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we say "prior to writing to JSON file" since a user can reach this code path through
DataFrame.save
, which is not related to table operation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, get rid of
:\n
and add a.
at the end of the message.