feat: Quote column names if required in error messages#5778
Merged
alamb merged 4 commits intoapache:mainfrom Apr 5, 2023
Merged
feat: Quote column names if required in error messages#5778alamb merged 4 commits intoapache:mainfrom
alamb merged 4 commits intoapache:mainfrom
Conversation
alamb
commented
Mar 29, 2023
| "Schema error: Schema contains duplicate \ | ||
| qualified field name \"t1\".\"c0\"", | ||
| &format!("{}", join.err().unwrap()) | ||
| join.unwrap_err().to_string(), |
Contributor
Author
There was a problem hiding this comment.
I cleaned these tests up to use a more standard unwrap_err() and to_string() pattern
| field name \"t1\".\"c0\" and unqualified field name \"c0\" which would be ambiguous", | ||
| &format!("{}", join.err().unwrap()) | ||
| ); | ||
| assert_contains!(join.unwrap_err().to_string(), |
Contributor
Author
There was a problem hiding this comment.
I switched to assert_contains as that includes the expected and actual in the message where assert!(..contains()) just says "false" when it fails
| } | ||
|
|
||
| #[test] | ||
| fn test_quote_identifier() -> Result<()> { |
Contributor
Author
There was a problem hiding this comment.
This test verifies that identifiers are properly quoted (and that when parsed, quoted identifiers are the same)
| pub fn quote_identifier(s: &str) -> String { | ||
| format!("\"{}\"", s.replace('"', "\"\"")) | ||
| pub fn quote_identifier(s: &str) -> Cow<str> { | ||
| if needs_quotes(s) { |
Contributor
Author
There was a problem hiding this comment.
this is the code change
Contributor
Author
Weijun-H
reviewed
Apr 3, 2023
Comment on lines
+171
to
+176
| if needs_quotes(s) { | ||
| Cow::Owned(format!("\"{}\"", s.replace('"', "\"\""))) | ||
| } else { | ||
| Cow::Borrowed(s) | ||
| } | ||
| } |
Member
|
LGTM |
Weijun-H
approved these changes
Apr 3, 2023
2c188a7 to
e8f6a4a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #5523
Closes #5625
Rationale for this change
Error messages are hard to read with so many unecessary
"What changes are included in this PR?
This work is based off of @Weijun-H 's great start in #5625 (🙏 )
Are these changes tested?
Yes -- both existing tests and new tets
Are there any user-facing changes?