Skip to content

Add support for query source in COPY .. TO statement #858

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

Merged
merged 2 commits into from
May 1, 2023

Conversation

aprimadi
Copy link
Contributor

Closes #857

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Looks great to me -- thank you @aprimadi

I had just one question related to the error case

let to = match self.parse_one_of_keywords(&[Keyword::FROM, Keyword::TO]) {
Some(Keyword::FROM) => false,
Some(Keyword::TO) => true,
_ => self.expected("FROM or TO", self.peek_token())?,
};
if !to {
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 we should remove this error in the parser per https://github.com/sqlparser-rs/sqlparser-rs#syntax-vs-semantics (if downstream crates want to error that is fine).

I don't feel super strongly on this point

what do you think @ankrgyl ?

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 argue that this is syntactic as the syntax is described here and is different for COPY .. FROM vs COPY .. TO. https://www.postgresql.org/docs/current/sql-copy.html.

Looking at DuckDB syntax graph also there seems to be difference syntactically between COPY .. FROM vs COPY .. TO. https://duckdb.org/docs/sql/statements/copy

But yeah let's wait on what @ankrgyl think about it. I'll go with whatever the consensus decide since I'm not an expert in various SQL dialects.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I said above, I think this way is fine (and kudos to you for covering it with tests). I agree let's see if @ankrgyl has any thoughts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the really fast review @alamb -- must be tough reviewing so many repos ❤️

Copy link
Contributor

Choose a reason for hiding this comment

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

🤯 most days

@alamb
Copy link
Contributor

alamb commented Apr 27, 2023

This PR appears to have some lint and complication errors

@aprimadi
Copy link
Contributor Author

Ah yes working on fixing it

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4821865552

  • 104 of 106 (98.11%) changed or added relevant lines in 3 files are covered.
  • 623 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+0.2%) to 86.079%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser.rs 13 14 92.86%
tests/sqlparser_postgres.rs 79 80 98.75%
Files with Coverage Reduction New Missed Lines %
src/ast/helpers/stmt_data_loading.rs 3 92.5%
src/dialect/mod.rs 3 95.16%
src/lib.rs 4 10.1%
tests/sqlparser_snowflake.rs 14 97.06%
src/dialect/snowflake.rs 17 92.77%
tests/sqlparser_common.rs 96 97.07%
src/parser.rs 162 81.92%
src/ast/mod.rs 324 78.19%
Totals Coverage Status
Change from base Build 4809268529: 0.2%
Covered Lines: 14216
Relevant Lines: 16515

💛 - Coveralls

@alamb alamb merged commit 0ff863b into apache:main May 1, 2023
@alamb
Copy link
Contributor

alamb commented May 1, 2023

Thanks again @aprimadi

@alamb alamb mentioned this pull request May 2, 2023
serprex pushed a commit to serprex/sqlparser-rs that referenced this pull request Nov 6, 2023
* Support identifiers beginning with digits in MySQL (apache#856)

* support COPY INTO in snowflake (apache#841)

Signed-off-by: Pawel Leszczynski <[email protected]>

* Add `dialect_from_str` and improve `Dialect` documentation (apache#848)

* Add `dialect_from_str` and improve `Dialect` documentation

* cleanup

* fix compilation with nostd

* Support multiple-table DELETE syntax (apache#855)

* Support `DISTINCT ON (...)` (apache#852)

* Support "DISTINCT ON (...)"

* a test

* fix the merge

* Test trailing commas (apache#859)

* test: add tests for trailing commas

* tweaks

* Add support for query source in COPY .. TO statement (apache#858)

* Add support for query source in COPY .. TO statement

* Fix compile error

* Fix logical merge conflict (apache#865)

* Fix tiny typo in custom_sql_parser.md (apache#864)

* Make Expr::Interval its own struct (apache#872)

* Make Expr::Interval its own struct

* Add test interval display

* Fix cargo fmt

* Include license file in published crate (apache#871)

* Add support for multiple expressions, order by in aggregations (apache#879)

* Add support for multiple expressions, order by in aggregations

* Fix formatting errors

* Resolve linter errors

* Add parse_multipart_identifier function to parser (apache#860)

* Add parse_multipart_identifier function to parser

* Update doc for parse_multipart_identifier

* Fix conflict

* feat: Add custom operator (apache#868)

* feat: Add custom operator

From apache#863

- It doesn't parse anything — I'm not sure how to parse ` SELECT 'a' REGEXP '^[a-d]';` with `REGEXP` as the operator... (but fine for my narrow purpose)
- If we need tests, where would I add them?

* Update src/ast/operator.rs

---------

Co-authored-by: Andrew Lamb <[email protected]>

* feat: Support MySQL's `DIV` operator (apache#876)

* feat: MySQL's DIV operator

* fix: do not use `_` prefix for used variable

---------

Co-authored-by: Andrew Lamb <[email protected]>

* truncate: table as optional keyword (apache#883)

Signed-off-by: Maciej Obuchowski <[email protected]>

* feat: add DuckDB dialect (apache#878)

* feat: add DuckDB dialect

* formatting

* fix conflict

* support // in GenericDialect

* add DucDbDialect to all_dialects

* add comment from suggestion

Co-authored-by: Andrew Lamb <[email protected]>

* fix: support // in GenericDialect

---------

Co-authored-by: Andrew Lamb <[email protected]>

* Add support for first, last aggregate function parsing (apache#882)

* Add order by parsing to functions

* Fix doc error

* minor changes

* Named window frames (apache#881)

* after over clause, named window can be parsed with window ... as after having clause

* Lint errors are fixed

* Support for multiple windows

* fix lint errors

* simplifications

* rename function

* Rewrite named window search in functional style

* Test added and some minor changes

* Minor changes on tests and namings, and semantic check is removed

---------

Co-authored-by: Mustafa Akur <[email protected]>
Co-authored-by: Mehmet Ozan Kabak <[email protected]>

* Fix merge conflict (apache#885)

* Update CHANGELOG for `0.34.0` release (apache#884)

* chore: Release sqlparser version 0.34.0

* Update criterion requirement from 0.4 to 0.5 in /sqlparser_bench (apache#890)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: Pawel Leszczynski <[email protected]>
Signed-off-by: Maciej Obuchowski <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: AviRaboah <[email protected]>
Co-authored-by: pawel.leszczynski <[email protected]>
Co-authored-by: Andrew Lamb <[email protected]>
Co-authored-by: Aljaž Mur Eržen <[email protected]>
Co-authored-by: Armin Primadi <[email protected]>
Co-authored-by: Okue <[email protected]>
Co-authored-by: Andrew Kane <[email protected]>
Co-authored-by: Mustafa Akur <[email protected]>
Co-authored-by: Jeffrey <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
Co-authored-by: eitsupi <[email protected]>
Co-authored-by: Maciej Obuchowski <[email protected]>
Co-authored-by: Berkay Şahin <[email protected]>
Co-authored-by: Mustafa Akur <[email protected]>
Co-authored-by: Mehmet Ozan Kabak <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for query source in COPY .. TO statement
3 participants