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

Add support for MSSQL's JSON_ARRAY/JSON_OBJECT expr #1507

Merged
merged 23 commits into from
Nov 18, 2024

Conversation

gaoqiangz
Copy link
Contributor

Solves #1506

src/ast/mod.rs Outdated Show resolved Hide resolved
src/ast/mod.rs Outdated Show resolved Hide resolved
src/ast/mod.rs Outdated Show resolved Hide resolved
src/ast/mod.rs Outdated Show resolved Hide resolved
@gaoqiangz
Copy link
Contributor Author

gaoqiangz commented Nov 10, 2024

I modified existing Function parsing,include a break change because JSON_OBJECT support FUNC(<expr> : <expr>) syntax:

DECLARE @id_key nvarchar(10) = N'id',@id_value nvarchar(64) = NEWID();
SELECT JSON_OBJECT(LOWER('USER_NAME') : USER_NAME(), LOWER(@id_key) : @id_value, 'sid':(SELECT @@SPID));

Break change:

pub enum FunctionArg {
    Named {
        name: Expr, // <<
        arg: FunctionArgExpr,
        operator: FunctionArgOperator,
    },
    Unnamed(FunctionArgExpr),
}

Please take a look!

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

Thanks @gaoqiangz I think this is looking good! Left some comments

src/ast/mod.rs Show resolved Hide resolved
src/parser/mod.rs Outdated Show resolved Hide resolved
src/parser/mod.rs Outdated Show resolved Hide resolved
tests/sqlparser_mssql.rs Show resolved Hide resolved
src/parser/mod.rs Outdated Show resolved Hide resolved
src/parser/mod.rs Outdated Show resolved Hide resolved
@gaoqiangz
Copy link
Contributor Author

I refactored function parameter list parsing,add some supports_named_fn_args_with_xxx functions to the Dialect trait,please take a look!

src/dialect/mod.rs Outdated Show resolved Hide resolved
src/dialect/mod.rs Outdated Show resolved Hide resolved
src/parser/mod.rs Outdated Show resolved Hide resolved
src/parser/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

LGTM! cc @alamb

@alamb alamb merged commit 92be237 into apache:main Nov 18, 2024
8 checks passed
@alamb
Copy link
Contributor

alamb commented Nov 18, 2024

Thanks again @gaoqiangz and @iffyio and @lovasoa

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