Skip to content

Comments

feat: Support generic expressions in SET statement#574

Merged
alamb merged 1 commit intoapache:mainfrom
cube-js:set-variable-expr
Aug 18, 2022
Merged

feat: Support generic expressions in SET statement#574
alamb merged 1 commit intoapache:mainfrom
cube-js:set-variable-expr

Conversation

@ovr
Copy link
Contributor

@ovr ovr commented Aug 16, 2022

Hello!

MySQL allows to use any kind of expression in SetVariable statement, for example:

SET sql_mode = CONCAT(@@sql_mode, ',STRICT_TRANS_TABLES')

Thanks

@ovr ovr force-pushed the set-variable-expr branch from da5b9b2 to ee2ba31 Compare August 16, 2022 11:05
@ovr ovr force-pushed the set-variable-expr branch from ee2ba31 to 42b56b6 Compare August 16, 2022 11:19
@coveralls
Copy link

coveralls commented Aug 16, 2022

Pull Request Test Coverage Report for Build 2867488628

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 32 of 32 (100.0%) changed or added relevant lines in 7 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.005%) to 85.428%

Files with Coverage Reduction New Missed Lines %
src/parser.rs 2 83.17%
Totals Coverage Status
Change from base Build 2863782747: -0.005%
Covered Lines: 9509
Relevant Lines: 11131

💛 - Coveralls

@alamb alamb changed the title feat: Support expression in SET statement feat: Support generic expressions in SET statement Aug 18, 2022
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.

This looks great -- thanks @ovr

#[test]
fn parse_select_count_distinct() {
let sql = "SELECT COUNT(DISTINCT + x) FROM customer";
let sql = "SELECT COUNT(DISTINCT +x) FROM customer";
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I was confused about this for a while, but then I see that +x is actually a unary op, so it makes sense to display it as +x rather than + x 👍

fn parse_unary_math() {
use self::Expr::*;
let sql = "- a + - b";
let sql = "-a + -b";
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@alamb alamb merged commit 6d8aacd into apache:main Aug 18, 2022
mcheshkov pushed a commit to cube-js/sqlparser-rs that referenced this pull request Sep 2, 2024
Can drop this after rebase on commit 6d8aacd "feat: Support expression in SET statement (apache#574)", first released in 0.21.0
mcheshkov pushed a commit to cube-js/sqlparser-rs that referenced this pull request Sep 3, 2024
Can drop this after rebase on commit 6d8aacd "feat: Support expression in SET statement (apache#574)", first released in 0.21.0
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.

4 participants