-
Notifications
You must be signed in to change notification settings - Fork 276
[Connector] Pojo To RowData Utility #726
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for the contribution @MehulBatra , I left some comments about the implementation, please let me know if you have any questions.
initializeFieldMap(); | ||
} | ||
|
||
private void initializeFieldMap() { |
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.
Instead of analyze the pojo class using reflection by ourselves, I would suggest directly using Flink Types.POJO(class)
to get the PojoTypeInfo
and we can get the Java Field
from it. If you look into the source code of TypeExtractor.createTypeInfo
, you will find devil is in the details...
Besides, we can't flatten all the nested fields, because there may be different fields with the same field name. Such nested POJO fields should be converted into nseted InternalRow
. We don't need to support this case and can just throw nested POJO fields, as we currently doesn't support nested row type.
* | ||
* @param <T> The POJO type to convert | ||
*/ | ||
public class PojoToRowDataConverter<T> { |
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.
I think we can learn the implementation from org.apache.flink.table.data.util.DataFormatConverters.PojoConverter
which 1. first checks the date type of schema
and the Java class of the Field
, and determine the concrete converter implementation (e.g., 3 different converters for TIMESTAMP type).
2. use the converter to convert the object into a GenericRow.
Thanks for the feedback. I will address these comments over the coming weekend and get back to you in case I am stuck! |
Purpose
Linked issue: #723
Brief change log:
Tests:
API and Format
No API or storage format changes.
Documentation
No documentation changes are required.