You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/08/19 17:55:36 UTC

[GitHub] [hudi] pratyakshsharma opened a new pull request #1987: [HUDI-1177]: fixed TaskNotSerializableException in TimestampBasedKeyGenerator

pratyakshsharma opened a new pull request #1987:
URL: https://github.com/apache/hudi/pull/1987


   ## *Tips*
   - *Thank you very much for contributing to Apache Hudi.*
   - *Please review https://hudi.apache.org/contributing.html before opening a pull request.*
   
   ## What is the purpose of the pull request
   
   *(For example: This pull request adds quick-start document.)*
   
   ## Brief change log
   
   *(for example:)*
     - *Modify AnnotationLocation checkstyle rule in checkstyle.xml*
   
   ## Verify this pull request
   
   *(Please pick either of the following options)*
   
   This pull request is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This pull request is already covered by existing tests, such as *(please describe tests)*.
   
   (or)
   
   This change added tests and can be verified as follows:
   
   *(example:)*
   
     - *Added integration tests for end-to-end.*
     - *Added HoodieClientWriteTest to verify the change.*
     - *Manually verified the change by running a job locally.*
   
   ## Committer checklist
   
    - [ ] Has a corresponding JIRA in PR title & commit
    
    - [ ] Commit message is descriptive of the change
    
    - [ ] CI is green
   
    - [ ] Necessary doc changes done or have another open PR
          
    - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] bhasudha commented on pull request #1987: [HUDI-1177]: fixed TaskNotSerializableException in TimestampBasedKeyGenerator

Posted by GitBox <gi...@apache.org>.
bhasudha commented on pull request #1987:
URL: https://github.com/apache/hudi/pull/1987#issuecomment-676698639


   @pratyakshsharma  I was able to verify your patch quickly using quickstart commands. Will wait for the build to pass. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] bhasudha commented on a change in pull request #1987: [HUDI-1177]: fixed TaskNotSerializableException in TimestampBasedKeyGenerator

Posted by GitBox <gi...@apache.org>.
bhasudha commented on a change in pull request #1987:
URL: https://github.com/apache/hudi/pull/1987#discussion_r473289742



##########
File path: hudi-spark/src/main/java/org/apache/hudi/keygen/TimestampBasedKeyGenerator.java
##########
@@ -153,7 +147,8 @@ public String getPartitionPath(GenericRecord record) {
    * @return the parsed partition path based on data type
    * @throws ParseException on any parse exception
    */
-  private String getPartitionPath(Object partitionVal) throws ParseException {
+  private String getPartitionPath(Object partitionVal) {
+    DateTimeFormatter inputFormatter = parser.getInputFormatter();

Review comment:
       @pratyakshsharma  InitIfNeeded() should be called from getPartitionPath that way for each getPartitionPath() call we dont create DateTimeFormatter objects. And initIfNeeded() should check for `if (inputFormatter == null) {`. The variables will be marked transient and dont get initialized in the constructor.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] vinothchandar commented on a change in pull request #1987: [HUDI-1177]: fixed TaskNotSerializableException in TimestampBasedKeyGenerator

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on a change in pull request #1987:
URL: https://github.com/apache/hudi/pull/1987#discussion_r473257409



##########
File path: hudi-spark/src/main/java/org/apache/hudi/keygen/parser/HoodieDateTimeParserImpl.java
##########
@@ -95,7 +86,15 @@ public String getOutputDateFormat() {
 
   @Override
   public DateTimeFormatter getInputFormatter() {
-    return this.inputFormatter;
+    TimestampType timestampType = TimestampType.valueOf(config.getString(Config.TIMESTAMP_TYPE_FIELD_PROP));
+    if (timestampType == TimestampType.DATE_STRING || timestampType == TimestampType.MIXED) {
+      DataSourceUtils.checkRequiredProperties(config,
+          Collections.singletonList(Config.TIMESTAMP_INPUT_DATE_FORMAT_PROP));
+      this.configInputDateFormatList = config.getString(Config.TIMESTAMP_INPUT_DATE_FORMAT_PROP, "");
+      return getInputDateFormatter();
+    }
+
+    return null;

Review comment:
       throw an exception?  returning null is like playing with fire :) 

##########
File path: hudi-spark/src/main/java/org/apache/hudi/keygen/TimestampBasedKeyGenerator.java
##########
@@ -153,7 +147,8 @@ public String getPartitionPath(GenericRecord record) {
    * @return the parsed partition path based on data type
    * @throws ParseException on any parse exception
    */
-  private String getPartitionPath(Object partitionVal) throws ParseException {
+  private String getPartitionPath(Object partitionVal) {
+    DateTimeFormatter inputFormatter = parser.getInputFormatter();

Review comment:
       let's move any other per record allocation here. 

##########
File path: hudi-spark/src/main/java/org/apache/hudi/keygen/TimestampBasedKeyGenerator.java
##########
@@ -153,7 +147,8 @@ public String getPartitionPath(GenericRecord record) {
    * @return the parsed partition path based on data type
    * @throws ParseException on any parse exception
    */
-  private String getPartitionPath(Object partitionVal) throws ParseException {
+  private String getPartitionPath(Object partitionVal) {
+    DateTimeFormatter inputFormatter = parser.getInputFormatter();

Review comment:
       let's make these `transient` and lazily init this as needed. 
   
   ```
   private void initIfNeeded() {
     if (inputFormatter != null) {
      this.inputFormatter = parser.getInputFormatter();
      this.partitionFormatter = DateTimeFormat.forPattern(outputDateFormat);
     }
   }
   ```
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] pratyakshsharma commented on a change in pull request #1987: [HUDI-1177]: fixed TaskNotSerializableException in TimestampBasedKeyGenerator

Posted by GitBox <gi...@apache.org>.
pratyakshsharma commented on a change in pull request #1987:
URL: https://github.com/apache/hudi/pull/1987#discussion_r473282621



##########
File path: hudi-spark/src/main/java/org/apache/hudi/keygen/TimestampBasedKeyGenerator.java
##########
@@ -153,7 +147,8 @@ public String getPartitionPath(GenericRecord record) {
    * @return the parsed partition path based on data type
    * @throws ParseException on any parse exception
    */
-  private String getPartitionPath(Object partitionVal) throws ParseException {
+  private String getPartitionPath(Object partitionVal) {
+    DateTimeFormatter inputFormatter = parser.getInputFormatter();

Review comment:
       I did not get this check, if (inputFormatter != null) then why are we re-initialising? Ok, you mean to say the variable will be marked transient and will still get initialised in constructor? `initIfNeeded()` gets called from `getPartitionPath()` then? Please help me understand. @vinothchandar 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] pratyakshsharma commented on a change in pull request #1987: [HUDI-1177]: fixed TaskNotSerializableException in TimestampBasedKeyGenerator

Posted by GitBox <gi...@apache.org>.
pratyakshsharma commented on a change in pull request #1987:
URL: https://github.com/apache/hudi/pull/1987#discussion_r473293742



##########
File path: hudi-spark/src/main/java/org/apache/hudi/keygen/TimestampBasedKeyGenerator.java
##########
@@ -153,7 +147,8 @@ public String getPartitionPath(GenericRecord record) {
    * @return the parsed partition path based on data type
    * @throws ParseException on any parse exception
    */
-  private String getPartitionPath(Object partitionVal) throws ParseException {
+  private String getPartitionPath(Object partitionVal) {
+    DateTimeFormatter inputFormatter = parser.getInputFormatter();

Review comment:
       ok, I was thinking on similar lines but got confused by that if condition. Let me do the changes. :) Thank you for the clarification. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] pratyakshsharma commented on a change in pull request #1987: [HUDI-1177]: fixed TaskNotSerializableException in TimestampBasedKeyGenerator

Posted by GitBox <gi...@apache.org>.
pratyakshsharma commented on a change in pull request #1987:
URL: https://github.com/apache/hudi/pull/1987#discussion_r473282800



##########
File path: hudi-spark/src/main/java/org/apache/hudi/keygen/parser/HoodieDateTimeParserImpl.java
##########
@@ -95,7 +86,15 @@ public String getOutputDateFormat() {
 
   @Override
   public DateTimeFormatter getInputFormatter() {
-    return this.inputFormatter;
+    TimestampType timestampType = TimestampType.valueOf(config.getString(Config.TIMESTAMP_TYPE_FIELD_PROP));
+    if (timestampType == TimestampType.DATE_STRING || timestampType == TimestampType.MIXED) {
+      DataSourceUtils.checkRequiredProperties(config,
+          Collections.singletonList(Config.TIMESTAMP_INPUT_DATE_FORMAT_PROP));
+      this.configInputDateFormatList = config.getString(Config.TIMESTAMP_INPUT_DATE_FORMAT_PROP, "");
+      return getInputDateFormatter();
+    }
+
+    return null;

Review comment:
       Taken care of this :) 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [hudi] vinothchandar merged pull request #1987: [HUDI-1177]: fixed TaskNotSerializableException in TimestampBasedKeyGenerator

Posted by GitBox <gi...@apache.org>.
vinothchandar merged pull request #1987:
URL: https://github.com/apache/hudi/pull/1987


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org