Skip to content

MsSQL TRY_CONVERT #1477

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 7 commits into from
Oct 20, 2024
Merged

MsSQL TRY_CONVERT #1477

merged 7 commits into from
Oct 20, 2024

Conversation

yoavcloud
Copy link
Contributor

This PR adds support to parse the MsSQL TRY_CONVERT function, similar to CONVERT

@yoavcloud yoavcloud changed the title Mssql try convert MsSQL TRY_CONVERT Oct 18, 2024
@@ -1023,7 +1023,8 @@ impl<'a> Parser<'a> {
self.parse_time_functions(ObjectName(vec![w.to_ident()]))
}
Keyword::CASE => self.parse_case_expr(),
Keyword::CONVERT => self.parse_convert_expr(),
Keyword::CONVERT => self.parse_convert_expr(false),
Keyword::TRY_CONVERT if dialect_of!(self is MsSqlDialect) => self.parse_convert_expr(true),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have the guard as a dialect method e.g. self.dialect.supports_try_convert()? We can probably include support for the generic dialect as well

@@ -495,6 +497,8 @@ fn parse_convert() {
ParserError::ParserError("Expected: an expression, found: )".to_owned()),
ms().parse_sql_statements(error_sql).unwrap_err()
);

ms().verified_expr("TRY_CONVERT(VARCHAR(MAX), 'foo')");
Copy link
Contributor

Choose a reason for hiding this comment

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

with the dialect method we can move this over to common.rs as a generic test over the dialects that support the feature

@yoavcloud yoavcloud requested a review from iffyio October 19, 2024 05:46
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.

@yoavcloud can we also add the flag to generic dialect? Other than that LGTM!

@yoavcloud yoavcloud requested a review from iffyio October 19, 2024 06:49
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

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.

Thanks @yoavcloud and @iffyio

@alamb alamb merged commit 45c5d69 into apache:main Oct 20, 2024
10 checks passed
@alamb
Copy link
Contributor

alamb commented Oct 20, 2024

Thanks agian @yoavcloud and @iffyio

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11429342019

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

  • 18 of 21 (85.71%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.004%) to 89.387%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dialect/generic.rs 1 2 50.0%
src/dialect/mod.rs 1 2 50.0%
src/dialect/mssql.rs 1 2 50.0%
Totals Coverage Status
Change from base Build 11428547119: -0.004%
Covered Lines: 30464
Relevant Lines: 34081

💛 - Coveralls

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