-
Notifications
You must be signed in to change notification settings - Fork 279
Fixing DateTime null parse issue in datawarehouse queries. #2231
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
Conversation
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
is this issue only happening for DWSQL or also for other DBs? |
ayush3797
reviewed
May 23, 2024
Please add before/after bug fix screenshots. That'll help. |
ayush3797
approved these changes
May 23, 2024
sample requests in text format preferred so that way we can copy/paste into our own GraphQL requests |
Co-authored-by: Ayush Agarwal <34566234+ayush3797@users.noreply.github.com>
/azp run |
….com/Azure/data-api-builder into rohkhann/FixingDateTimeNullParsingDW
/azp run |
/azp run |
/azp run |
vadeveka
approved these changes
May 24, 2024
rusamant
approved these changes
May 24, 2024
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.
Why make this change?
When we moved to the new form of query execution: #2068, we got rid of the resolver middleware that had the function:
public static bool RepresentsNullValue(JsonElement element) { return (string.IsNullOrEmpty(element.ToString()) && element.GetRawText() == "null"); }
which would check if the returned string was null. This was useful for datetime values in datawarehouse where because of the use of string agg we have to return null as a string.
The error that is seen is: "The string 'null' was not recognized as a valid DateTime. There is an unknown word starting at index '0'.
What is this change?
This change switches to leveraging tryparse for the datetime field value. This allows us to handle the null case, as if the string is null, tryparse will just fail and return null for date.
How was this tested?
A test has been added to ensure that datetime null case is handled.

Before:
Running a sample query which checks for a date column:
query { tests { items { ReleaseDate } } }
After fix: