Skip to content
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-30150][SQL] ADD FILE, ADD JAR, LIST FILE & LIST JAR Command do not accept quoted path #26779

Closed
wants to merge 6 commits into from

Conversation

iRakson
Copy link
Contributor

@iRakson iRakson commented Dec 6, 2019

What changes were proposed in this pull request?

add file "abc.txt" and add file 'abc.txt' are not supported.
For these two spark sql gives FileNotFoundException.
Only add file abc.txt is supported currently.

After these changes path can be given as quoted text for ADD FILE, ADD JAR, LIST FILE, LIST JAR commands in spark-sql

Why are the changes needed?

In many of the spark-sql commands (like create table ,etc )we write path in quoted format only. To maintain this consistency we should support quoted format with this command as well.

Does this PR introduce any user-facing change?

Yes. Now users can write path with quotes.

How was this patch tested?

Manually tested.

@iRakson
Copy link
Contributor Author

iRakson commented Dec 6, 2019

cc @cloud-fan

@@ -357,7 +357,7 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder(conf) {
* }}}
*/
override def visitManageResource(ctx: ManageResourceContext): LogicalPlan = withOrigin(ctx) {
val mayebePaths = remainder(ctx.identifier).trim
val mayebePaths = pathWrapper(remainder(ctx.identifier).trim)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use string literal or identifier rule in ANTLER rather than manually fixing here from identifer? BTW, does Hive support that case as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that approach @HyukjinKwon addressed above looks nicer to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the grammar to take string literal as well for ADD/LIST.

Now all of add file abc.txt, add file 'abc.txt' and add file "abc.txt" are supported.

@maropu
Copy link
Member

maropu commented Dec 9, 2019

Can you add tests for that?

@iRakson
Copy link
Contributor Author

iRakson commented Dec 9, 2019

Can you add tests for that?

Yeah Sure.

@iRakson
Copy link
Contributor Author

iRakson commented Dec 9, 2019

Test Cases Added For all the 4 commands.
Please review this @maropu , @HyukjinKwon

@maropu
Copy link
Member

maropu commented Dec 10, 2019

Can you update the title to make it clearer? Is this pr not only for AddFile, right?

@maropu
Copy link
Member

maropu commented Dec 10, 2019

ok to test

@iRakson iRakson changed the title [SPARK-30150][SQL]AddFile Command do not accept quoted path [SPARK-30150][SQL]ADD FILE, ADD JAR, LIST FILE & LIST JAR Command do not accept quoted path Dec 10, 2019
@HyukjinKwon
Copy link
Member

@iRakson does Hive support this case?

@iRakson
Copy link
Contributor Author

iRakson commented Dec 10, 2019

@HyukjinKwon No. Path passed in hive is unquoted i.e not as string literal.

@SparkQA
Copy link

SparkQA commented Dec 10, 2019

Test build #115061 has finished for PR 26779 at commit fbf1add.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 10, 2019

Test build #115084 has finished for PR 26779 at commit 7aafe85.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@iRakson
Copy link
Contributor Author

iRakson commented Dec 10, 2019

please re-test this one.

@maropu
Copy link
Member

maropu commented Dec 10, 2019

retest this please

@SparkQA
Copy link

SparkQA commented Dec 10, 2019

Test build #115100 has finished for PR 26779 at commit 7aafe85.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.


test("manage resources") {
assertEqual("ADD FILE abc.txt", AddFileCommand("abc.txt"))
assertEqual("ADD FILE \'abc.txt\'", AddFileCommand("abc.txt"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is \' the same as ' here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we use '? it's easier to read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloud-fan Yes, Its better that way. I have made the changes.

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-30150][SQL]ADD FILE, ADD JAR, LIST FILE & LIST JAR Command do not accept quoted path [SPARK-30150][SQL] ADD FILE, ADD JAR, LIST FILE & LIST JAR Command do not accept quoted path Dec 11, 2019
assertEqual("ADD FILE abc.txt", AddFileCommand("abc.txt"))
assertEqual("ADD FILE \'abc.txt\'", AddFileCommand("abc.txt"))
assertEqual("ADD FILE \"/path/to/abc.txt\"", AddFileCommand("/path/to/abc.txt"))
assertEqual("LIST FILE abc.txt", ListFilesCommand("abc.txt".split("\\s+")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we use simply Array("/path//abc.txt") instead of "abc.txt".split("\\s+")? (here and the below LIST test cases)

Copy link
Contributor Author

@iRakson iRakson Dec 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List commands are using .split("\\s+") on path given to them. Thus we have to do same here. @dongjoon-hyun

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is a test case. You can use the result of .split("\\s+").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I will use the result of .split("\s+").

assertEqual("LIST JAR \'abc.jar\'", ListJarsCommand("abc.jar".split("\\s+")))
assertEqual("LIST JAR \"abc.jar\"", ListJarsCommand("abc.jar".split("\\s+")))
assertEqual("ADD FILE /path with space/abc.txt", AddFileCommand("/path with space/abc.txt"))
assertEqual("ADD JAR /path with space/abc.jar", AddJarCommand("/path with space/abc.jar"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although our parser will accept without any differences, shall we have a test case for Window-path, too?

Copy link
Contributor Author

@iRakson iRakson Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dongjoon-hyun Is it required to add test cases for window-path?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's OK. We know that the parser accepts anything, we just need to prove that quoted path works.

@SparkQA
Copy link

SparkQA commented Dec 11, 2019

Test build #115163 has finished for PR 26779 at commit b808d51.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 2936507 Dec 12, 2019
@iRakson
Copy link
Contributor Author

iRakson commented Dec 12, 2019

Thanks all for reviewing this PR :) and merging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants