Skip to content

[SPARK-37558][DOC] Improve spark sql cli document - #34821

Closed
AngersZhuuuu wants to merge 22 commits into
apache:masterfrom
AngersZhuuuu:SPARK-37558
Closed

[SPARK-37558][DOC] Improve spark sql cli document#34821
AngersZhuuuu wants to merge 22 commits into
apache:masterfrom
AngersZhuuuu:SPARK-37558

Conversation

@AngersZhuuuu

@AngersZhuuuuAngersZhuuuu commented Dec 6, 2021

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Current Spark SQL CLI doc just show simple usage. In this pr we add a detail doc for spark sql cli.

Why are the changes needed?

Make doc about Spark SQL CLI more clear. help user to use this command line tool.

Does this PR introduce any user-facing change?

No

How was this patch tested?

127 0 0 1_4000_xxx html

@SparkQA

Copy link
Copy Markdown

Test build #145954 has finished for PR 34821 at commit 01848dc.

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

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50427/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50427/

Comment threaddocs/sql-distributed-sql-engine.md Outdated
Comment threaddocs/sql-distributed-sql-engine.md Outdated
Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
@SparkQA

Copy link
Copy Markdown

Test build #145970 has finished for PR 34821 at commit 7a9ecbf.

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

@AngersZhuuuuAngersZhuuuu changed the title [WIP][SPARK-37558][DOC] Improve spark sql cli document[SPARK-37558][DOC] Improve spark sql cli documentDec 7, 2021
@AngersZhuuuu

Copy link
Copy Markdown
ContributorAuthor

ping @cloud-fan

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50445/

@SparkQA

Copy link
Copy Markdown

Test build #145972 has finished for PR 34821 at commit a0218f8.

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

## Spark SQL CLI Interactive Shell Commands

When `./bin/spark-sql` is run without either the `-e` or `-f` option, it enters interactive shell mode.
Use `;` (semicolon) to terminate commands, but user can escape `;` by `\\;`. Comments in scripts can be specified using the `--` prefix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if ; is not the end of the line? does it still terminate commands?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should explain more about ;

  • what if it's inside a comment? SELECT /* xxx; */ 1;
  • is ; the only way to terminate commands? what if I type SELECT 1 and then press enter?
  • can we put multiple commands in a single line? SELECT 1; SELECT 2;

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

How about current?

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50447/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50445/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50447/

@SparkQA

Copy link
Copy Markdown

Test build #145977 has finished for PR 34821 at commit cea5be4.

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

Use `;` (semicolon) to terminate commands. Notice:
1. CLI use `;` to terminate commands only when it's at the end of line and it's not escaped by `\\;`.
2. `;` is the only way to terminate commands, if user type `SELECT 1` and press enter, console will just wait for input.
3. If user type multiple commands in one line like `SELECT 1; SELECT 2;`, commands `SELECT 1` and `SELECT 2` will be executed separatly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and CLI only shows the result of the last command?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

and CLI only shows the result of the last command?

No, both result.

spark-sql> select 1; select 2;
1
Time taken: 3.819 seconds, Fetched 1 row(s)
2
Time taken: 0.077 seconds, Fetched 1 row(s)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the user types multiple commands in one line like SELECT 1; SELECT 2;, then commands SELECT 1 and SELECT 2 will be executed separately.

/* This is a comment contains ;
*/ SELECT 1;
```
it will terminate commands into `/* This is a comment contains ` and `*/ SELECT 1`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and we hit failures when executing /* This is a comment contains

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

spark-sql> /* This is a comment contains ;
Error in query:
Unclosed bracketed comment(line 1, pos 0)
== SQL ==
/* This is a comment contains ;
^^^
spark-sql> */ SELECT 1;
Error in query:
extraneous input '*/' expecting {'(', 'ADD', 'ALTER', 'ANALYZE', 'CACHE', 'CLEAR', 'COMMENT', 'COMMIT', 'CREATE', 'DELETE', 'DESC', 'DESCRIBE', 'DFS', 'DROP', 'EXPLAIN', 'EXPORT', 'FROM', 'GRANT', 'IMPORT', 'INSERT', 'LIST', 'LOAD', 'LOCK', 'MAP', 'MERGE', 'MSCK', 'REDUCE', 'REFRESH', 'REPLACE', 'RESET', 'REVOKE', 'ROLLBACK', 'SELECT', 'SET', 'SHOW', 'START', 'TABLE', 'TRUNCATE', 'UNCACHE', 'UNLOCK', 'UPDATE', 'USE', 'VALUES', 'WITH'}(line 1, pos 5)
== SQL ==
*/ SELECT 1
-----^^^
spark-sql>

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50452/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50452/

@AngersZhuuuu

Copy link
Copy Markdown
ContributorAuthor

Any more suggestion?

Comment threaddocs/index.md Outdated
Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
-- This is a comment;
SELECT 1;
```
This comment line will just be ignored. If `;` in a bracketed command and not at the end of line,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

then this comment line will be ignored. If ; appears in a bracketed command

(and similarly for the other lines below)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
</tr>
<tr>
<td><code>dfs &lt;dfs command&gt;</code></td>
<td>Executes a <a href="https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HDFSCommands.html#dfs">dfs command</a> from the Hive shell.</td>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this only for executing commands vs HDFS or would it work on other distributed storage?
We should say HDFS if it's HDFS.
Also, not "Hive shell" here right?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done, how about current?

Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
@SparkQA

Copy link
Copy Markdown

Test build #146000 has finished for PR 34821 at commit 36ce29f.

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

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50476/

@AngersZhuuuu

Copy link
Copy Markdown
ContributorAuthor
Error in loadNamespace(x) : there is no package called ‘pkgdown’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted

Can you rebase this PR to pass Github Actions? It checks the documentation build.

Done

@SparkQA

Copy link
Copy Markdown

Test build #146158 has finished for PR 34821 at commit d9f150c.

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

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50631/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50631/

Comment threaddocs/sql-distributed-sql-engine-spark-sql-cli.md Outdated
## Path interpretation

Spark SQL CLI supports running SQL from initialization script file(`-i`) or normal SQL file(`-f`), If path url don't have a schema component, the path will be handled as local file.
For example: `/path/to/spark-sql-cli.sql` equals to `file:///path/to/spark-sql-cli.sql`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's also mention that people can use Hadoop supported filesystem such as s3://...

@cloud-fancloud-fan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM except for a few minor comments

@SparkQA

Copy link
Copy Markdown

Test build #146189 has finished for PR 34821 at commit 453f260.

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

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50662/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50662/

@SparkQA

Copy link
Copy Markdown

Test build #146220 has finished for PR 34821 at commit d4f6778.

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

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50694/

@SparkQA

Copy link
Copy Markdown

Test build #146223 has finished for PR 34821 at commit 2b6f130.

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

@AngersZhuuuu

Copy link
Copy Markdown
ContributorAuthor

LGTM except for a few minor comments

Scrrenshot updated in pr desc

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50697/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50694/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50697/

@SparkQA

Copy link
Copy Markdown

Test build #146227 has finished for PR 34821 at commit 147d8b0.

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

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50701/

@SparkQA

Copy link
Copy Markdown

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50701/

@cloud-fan

Copy link
Copy Markdown
Contributor

thanks, merging to master!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@AngersZhuuuu@SparkQA@cloud-fan@srowen