Added InferDictionariesFromRecords flag to JSON TP#1430
Merged
cartermp merged 3 commits intofsprojects:mainfrom Feb 28, 2022
Merged
Added InferDictionariesFromRecords flag to JSON TP#1430cartermp merged 3 commits intofsprojects:mainfrom
cartermp merged 3 commits intofsprojects:mainfrom
Conversation
JSON TP always projects json record fields into the properties of generated types. Sometimes it is not desirable. The added flag will allow to infer dictionaries from the records if the names of all the fields of similar records in the provider's training data are inferred to the same non-string primitive type (by type inference rules). The flag is not set by default for backwards compatibility.
- removed extra pipe ! added missing newline at end of the files + code reusing
Contributor
|
Suggest |
dsyme
approved these changes
Feb 24, 2022
Contributor
|
I left a couple of suggestions, but otherwise marked as approved, the code looks great |
- dropped overused lambda expressions * renamed the InferDictionariesFromRecords flag into PreferDictionaries
Contributor
Author
|
done |
cartermp
approved these changes
Feb 28, 2022
Collaborator
|
Thanks! |
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.
JSON TP always projects json record fields into the properties
of generated types. Sometimes it is not desirable. The added
flag will allow to infer dictionaries from the records if the names
of all the fields of similar records in the provider's training data
are inferred to the same non-string primitive type (by type inference
rules). The flag is not set by default for backwards compatibility.
The current implementation makes it meaningless to process such data in the JSON Provider:
{ "sales": { "2022-01-13": { "count": 3 }, "2022-01-23": { "count": 5 }, "2022-01-28": { "count": 4 }, "2022-02-01": { "count": 5 }, "2022-02-07": { "count": 1 }, "2022-02-13": { "count": 2 } } }With this PR, for example, it is easy to find out from the above data how many sales were in February:
In addition to the
Items: (InferedKey * InferedValue) seqproperty specified in the code above, the generated dictionary-like type contains theCount,IsEmpty,Keys,Valuesproperties, theItemindexed property, and theContainsKey,TryFindmethods, similar to the members ofFSharp.Collections.Map