Skip to content

Conversation

@dtenedor
Copy link
Contributor

What changes were proposed in this pull request?

This PR adds documentation for SQL pipe syntax.

Why are the changes needed?

It provides a reference table of available operators and describes how the syntax works in each of the supported circumstances.

Does this PR introduce any user-facing change?

No, this is a documentation-only change.

How was this patch tested?

N/A

Was this patch authored or co-authored using generative AI tooling?

No

@github-actions github-actions bot added the DOCS label Nov 14, 2024
@dtenedor dtenedor changed the title commit [SPARK-50309][SQL] Add documentation for SQL pipe syntax Nov 14, 2024
@dtenedor dtenedor marked this pull request as ready for review November 14, 2024 21:30
@dtenedor
Copy link
Contributor Author

cc @cloud-fan @gengliangwang here is documentation support for the new SQL pipe syntax, which is nearly completed.

@gengliangwang
Copy link
Member

@dtenedor The doc looks good to me overall.
Do we consider showing more examples like https://github.com/google/zetasql/blob/master/docs/pipe-syntax.md?

@dtenedor
Copy link
Contributor Author

dtenedor commented Nov 15, 2024

@gengliangwang thanks for your review! I updated the docs with more examples and information per recommendation, please take another look.

#### LIMIT

```sql
|> LIMIT <n> [OFFSET <m>]
Copy link
Contributor

Choose a reason for hiding this comment

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

is OFFSET m LIMIT n allowed?

Copy link
Contributor

Choose a reason for hiding this comment

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

and OFFSET only?

Copy link
Contributor Author

@dtenedor dtenedor Nov 15, 2024

Choose a reason for hiding this comment

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

@cloud-fan I checked, and OFFSET is allowed without LIMIT, and vice versa. But if both are present, LIMIT must come before OFFSET. Updated this part accordingly.

Copy link
Contributor

@cloud-fan cloud-fan left a comment

Choose a reason for hiding this comment

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

nice doc!

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-50309][SQL] Add documentation for SQL pipe syntax [SPARK-50309][DOCS] Add documentation for SQL pipe syntax Nov 15, 2024
Copy link
Member

@gengliangwang gengliangwang left a comment

Choose a reason for hiding this comment

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

Nice

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-50309][DOCS] Add documentation for SQL pipe syntax [SPARK-50309][DOCS] Document SQL Pipe Syntax Nov 15, 2024
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM.

@gengliangwang
Copy link
Member

Thanks, merging to master

dongjoon-hyun added a commit that referenced this pull request Dec 7, 2024
…x.md`

### What changes were proposed in this pull request?

This PR aims to fix invalid `CREATE TABLE` syntax in `sql-pipe-syntax.md`.

It seems that we missed during documentation. It causes `ParseException: Operation not allowed` .
- #48852

### Why are the changes needed?

The current documentation is here.

- https://apache.github.io/spark/sql-pipe-syntax.html#from-or-table

**BEFORE**
```
spark-sql (default)> CREATE TABLE t(col INT) AS VALUES (0), (1);

Operation not allowed: Schema may not be specified in a Create Table As Select (CTAS) statement.
== SQL (line 1, position 1) ==
CREATE TABLE t(col INT) AS VALUES (0), (1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

**AFTER**
```
spark-sql (default)> CREATE TABLE t AS VALUES (0), (1);
Time taken: 0.142 seconds

spark-sql (default)> TABLE t;
1
0
Time taken: 0.287 seconds, Fetched 2 row(s)
```

### Does this PR introduce _any_ user-facing change?

No, this is a documentation-only change of the unreleased SQL Pipe syntax.

### How was this patch tested?

Manual review.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #49096 from dongjoon-hyun/SPARK-50512.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
Sign up for free to 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.

5 participants