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
API to expose the contract/rules imposed by pinot on tableConfig #10655
API to expose the contract/rules imposed by pinot on tableConfig #10655
Conversation
It consists of all the possible DataTypes for each FieldType and the default null value for each of these combinations.
Codecov Report
@@ Coverage Diff @@
## master #10655 +/- ##
=============================================
+ Coverage 27.66% 70.23% +42.57%
- Complexity 58 6431 +6373
=============================================
Files 2090 2107 +17
Lines 112578 113835 +1257
Branches 16972 17201 +229
=============================================
+ Hits 31145 79955 +48810
+ Misses 78333 28286 -50047
- Partials 3100 5594 +2494
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1507 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@ApiOperation(value = "Get TableConfig metadata", notes = "Get TableConfig metadata") | ||
public String getFieldSpecMetadata() { | ||
try { | ||
return JsonUtils.objectToString(FieldSpec.FIELD_SPEC_METADATA); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return just the object. It'll automatically be jsonified.
} | ||
|
||
public static class DataTypeMetadata { | ||
public FieldSpec.DataType _name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataType has a bunch of other useful properties that can be part of the response.
private final DataType _storedType;
private final int _size;
private final boolean _sortable;
private final boolean _numeric;
Think we should include all that in the API result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Maybe I need to introduce a separate dataTypes
property at fieldTypes
level so as to not have the dataType
specific info under allowedDataTypes
and that too with redundant replication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the wrapper structure to accommodate the data type properties.
I understand the re-org of code to have metadata on fieldSpec, but why expose this via API? How will a user of Pinot make use of this API? Should we call the API |
Hey @mcvsubbu as mentioned in the issue (link in description) the API consumer will be mostly another application built on top of pinot rather than a pinot user. Motivation is to enable client side user data input validations. The endpoint should return in general what are the constraints imposed by pinot on the table config or schema. It's not specific to any particular table or segment. Using this info client application should be able to impose data validations dynamically. I have no strong reason behind the endpoint path, I can change it to |
Hey @mcvsubbu I have changed the endpoint path as suggested, let me know if the above comment addressed your concerns. |
This PR tries to address the items mention in issue #10647
Changes :
Schema.validate()
toSchema.validate(FieldType fieldType, DataType dataType)
so that the code can be reused to just validate if a DataType is allowed by a FieldType.FieldSpec.FIELD_SPEC_METADATA
to hold the spec metadata./schemas/fieldSpec