You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/29 06:43:07 UTC

[GitHub] [flink] pyscala opened a new pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

pyscala opened a new pull request #13834:
URL: https://github.com/apache/flink/pull/13834


   
   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   Support to parse millisecond for TIME type in CSV format
   
   
   ## Brief change log
   
   Support to parse millisecond for TIME type in CSV format
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   `testSerializeDeserializeForTime() `
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: ( no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)


----------------------------------------------------------------
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] [flink] flinkbot commented on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718397596


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit 9a45aa49f38b831a4158debefa28f1443a21129c (Thu Oct 29 06:44:57 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 3792d96b470ee584cd60265925bf578d65fffa64 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] wuchong commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514842981



##########
File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvToRowDataConverters.java
##########
@@ -221,12 +221,22 @@ private int convertToDate(JsonNode jsonNode) {
 		return (int) Date.valueOf(jsonNode.asText()).toLocalDate().toEpochDay();
 	}
 
-	private int convertToTime(JsonNode jsonNode) {
+	private CsvToRowDataConverter convertToTime(TimeType timeType) {
+		final int precision = timeType.getPrecision();
 		// csv currently is using Time.valueOf() to parse time string
-		LocalTime localTime = Time.valueOf(jsonNode.asText()).toLocalTime();
 		// TODO: FLINK-17525 support millisecond and nanosecond
 		// get number of milliseconds of the day
-		return localTime.toSecondOfDay() * 1000;
+		return jsonNode -> {
+			LocalTime localTime = LocalTime.parse(jsonNode.asText());
+			if (precision == 3) {
+				return localTime.toNanoOfDay() / 1000_000L;
+			} else if (precision == 0) {
+				return localTime.toSecondOfDay() * 1000L;
+			} else {
+				throw new IllegalArgumentException("Csv does not support TIME type " +
+					"with precision: " + precision + ", it only supports precision 0 or 3.");
+			}
+		};

Review comment:
       ```java
   		final int precision = timeType.getPrecision();
   		if (precision > 3) {
   			throw new IllegalArgumentException("CSV format does not support TIME type " +
   				"with precision: " + precision + ", it only supports precision 0 ~ 3.");
   		}
   		// get number of milliseconds of the day
   		return jsonNode -> {
   			LocalTime localTime = LocalTime.parse(jsonNode.asText());
   			if (precision == 0) {
   				return localTime.toSecondOfDay() * 1000L;
   			} else {
   				return (int) (localTime.toNanoOfDay() / 1000_000L);
   			}
   		};
   ```
   Throws exception in compile phase instead during runtime. 
   Besides, we can also support precision 0~3.

##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),

Review comment:
       Why not reuse the `testNullableField` method?

##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232421",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.23",
+			"12:12:12.23",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(0),
+			"12:12:12.23",
+			"12:12:12",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+
+		int precision = 2;
+		String expectedMessage = String.format("Csv does not support TIME type with precision: %d, it only supports precision 0 or 3.", precision);
+		String actualMessage = null;
+		try {
+			testFieldForTime(
+				TIME(precision),
+				"12:12:12.23",
+				"12:12:12",
+				(deserSchema) -> deserSchema.setNullLiteral("null"),
+				(serSchema) -> serSchema.setNullLiteral("null"),
+				",");
+		} catch (Exception e) {
+			actualMessage = e.getCause().getMessage();
+		}
+		assertEquals(expectedMessage, actualMessage);

Review comment:
       ```suggestion
   				",");
   				fail("Exception should be thrown.");
   		} catch (Exception e) {
   			assertEquals(expectedMessage, e.getCause().getMessage());
   		}
   ```

##########
File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/RowDataToCsvConverters.java
##########
@@ -128,7 +128,7 @@ private static RowFieldConverter createRowFieldConverter(LogicalType fieldType)
 			case DATE:
 				return (csvMapper, container, row, pos) -> convertDate(row.getInt(pos), container);
 			case TIME_WITHOUT_TIME_ZONE:
-				return (csvMapper, container, row, pos) -> convertTime(row.getInt(pos), container);
+				return (csvMapper, container, row, pos) -> convertTime(row.getLong(pos), container);

Review comment:
       We should still use `getInt`, because we always use `int` to represent number of milliseconds of the day in Flink SQL internally. See Javadoc of `RowData`.

##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232421",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.23",
+			"12:12:12.23",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(0),

Review comment:
       Add more tests for `TIME(1)`, `TIME(2)`.




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8674",
       "triggerID" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741",
       "triggerID" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] wuchong commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r519662950



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -320,6 +339,34 @@ private void testField(
 		assertEquals(expectedCsv, new String(serializedRow));
 	}
 
+	private void testFieldForTime(

Review comment:
       This is never used. 

##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");
+		int precision = 5;
+		String expectedMessage = String.format("Csv does not support TIME type with precision: %d, it only supports precision 0 ~ 3.", precision);
+		try {
+			testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       This will not fail. Because it is not `TIME(5)`. 
   
   You should add `fail();` if you want to verify it should fail. 

##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");
+		int precision = 5;
+		String expectedMessage = String.format("Csv does not support TIME type with precision: %d, it only supports precision 0 ~ 3.", precision);

Review comment:
       Why not hard code the exception message?

##########
File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvToRowDataConverters.java
##########
@@ -221,12 +221,27 @@ private int convertToDate(JsonNode jsonNode) {
 		return (int) Date.valueOf(jsonNode.asText()).toLocalDate().toEpochDay();
 	}
 
-	private int convertToTime(JsonNode jsonNode) {
+	private CsvToRowDataConverter convertToTime(TimeType timeType) {
+		final int precision = timeType.getPrecision();
 		// csv currently is using Time.valueOf() to parse time string
-		LocalTime localTime = Time.valueOf(jsonNode.asText()).toLocalTime();
 		// TODO: FLINK-17525 support millisecond and nanosecond
 		// get number of milliseconds of the day
-		return localTime.toSecondOfDay() * 1000;
+		if (precision > 3) {
+			throw new IllegalArgumentException("Csv does not support TIME type " +
+				"with precision: " + precision + ", it only supports precision 0 ~ 3.");
+		}
+		return jsonNode -> {
+			LocalTime localTime = LocalTime.parse(jsonNode.asText());
+			int mills = (int) (localTime.toNanoOfDay() / 1000_000L);
+			if (precision == 2) {
+				mills = mills / 10 * 10;

Review comment:
       Could you add a comment "this is for rounding off values out of precision"?

##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       All of these only test the deserialization. We should also add tests for serialization. I think we can use `testNullableField` for this purpose. 
   
   Besides, we can rename method `testField(fieldType, csvValue, value, deserializationConfig, fieldDelimiter)` to `testFieldSerialization` to be more specific. 




----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521302925



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       rename method  `testField(fieldType, csvValue, value, deserializationConfig, fieldDelimiter)` to `testFieldSerialization` ?  or `testFieldDeserialization` ?




----------------------------------------------------------------
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] [flink] wuchong commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521343390



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       Rename to `testFieldDeserialization`. 




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8674",
       "triggerID" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741",
       "triggerID" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "triggerType" : "PUSH"
     }, {
       "hash" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485",
       "triggerID" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741) 
   * 63f6644db59a1a512ceef894317b3bf29355b7a0 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521311963



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       The reason for not using `testNullableField ` can be seen in our previous dialogue.




----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521295218



##########
File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvToRowDataConverters.java
##########
@@ -221,12 +221,27 @@ private int convertToDate(JsonNode jsonNode) {
 		return (int) Date.valueOf(jsonNode.asText()).toLocalDate().toEpochDay();
 	}
 
-	private int convertToTime(JsonNode jsonNode) {
+	private CsvToRowDataConverter convertToTime(TimeType timeType) {
+		final int precision = timeType.getPrecision();
 		// csv currently is using Time.valueOf() to parse time string
-		LocalTime localTime = Time.valueOf(jsonNode.asText()).toLocalTime();
 		// TODO: FLINK-17525 support millisecond and nanosecond
 		// get number of milliseconds of the day
-		return localTime.toSecondOfDay() * 1000;
+		if (precision > 3) {
+			throw new IllegalArgumentException("Csv does not support TIME type " +
+				"with precision: " + precision + ", it only supports precision 0 ~ 3.");
+		}
+		return jsonNode -> {
+			LocalTime localTime = LocalTime.parse(jsonNode.asText());
+			int mills = (int) (localTime.toNanoOfDay() / 1000_000L);
+			if (precision == 2) {
+				mills = mills / 10 * 10;

Review comment:
       ok
   




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][csv] Fix CSV format is unable to parse millisecond for TIME type

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8674",
       "triggerID" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741",
       "triggerID" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "triggerType" : "PUSH"
     }, {
       "hash" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "status" : "CANCELED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485",
       "triggerID" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "triggerType" : "PUSH"
     }, {
       "hash" : "6dd7a167a257fe6379340600a53ab4262c35f62f",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9486",
       "triggerID" : "6dd7a167a257fe6379340600a53ab4262c35f62f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 63f6644db59a1a512ceef894317b3bf29355b7a0 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485) 
   * 6dd7a167a257fe6379340600a53ab4262c35f62f Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9486) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][csv] Fix CSV format is unable to parse millisecond for TIME type

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8674",
       "triggerID" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741",
       "triggerID" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "triggerType" : "PUSH"
     }, {
       "hash" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485",
       "triggerID" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "triggerType" : "PUSH"
     }, {
       "hash" : "6dd7a167a257fe6379340600a53ab4262c35f62f",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9486",
       "triggerID" : "6dd7a167a257fe6379340600a53ab4262c35f62f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741) 
   * 63f6644db59a1a512ceef894317b3bf29355b7a0 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485) 
   * 6dd7a167a257fe6379340600a53ab4262c35f62f Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9486) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521298080



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");
+		int precision = 5;
+		String expectedMessage = String.format("Csv does not support TIME type with precision: %d, it only supports precision 0 ~ 3.", precision);
+		try {
+			testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       fix it




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 3792d96b470ee584cd60265925bf578d65fffa64 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582) 
   * dfa6b28695625848a5798b38f7aa38b67029797a UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9a45aa49f38b831a4158debefa28f1443a21129c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] wuchong commented on pull request #13834: [FLINK-19872][csv] Fix CSV format is unable to parse millisecond for TIME type

Posted by GitBox <gi...@apache.org>.
wuchong commented on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-725904101


   Merging...


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9a45aa49f38b831a4158debefa28f1443a21129c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567) 
   * 3792d96b470ee584cd60265925bf578d65fffa64 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514891230



##########
File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/RowDataToCsvConverters.java
##########
@@ -128,7 +128,7 @@ private static RowFieldConverter createRowFieldConverter(LogicalType fieldType)
 			case DATE:
 				return (csvMapper, container, row, pos) -> convertDate(row.getInt(pos), container);
 			case TIME_WITHOUT_TIME_ZONE:
-				return (csvMapper, container, row, pos) -> convertTime(row.getInt(pos), container);
+				return (csvMapper, container, row, pos) -> convertTime(row.getLong(pos), container);

Review comment:
       Will overflow when supporting nanosecond precision in the future




----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514886767



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232421",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.23",
+			"12:12:12.23",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),
+			",");
+		testFieldForTime(
+			TIME(0),

Review comment:
       ok




----------------------------------------------------------------
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] [flink] flinkbot commented on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9a45aa49f38b831a4158debefa28f1443a21129c UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514983810



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),

Review comment:
       @wuchong 
   the following code 
   `Row actualRow = (Row) DataFormatConverters.getConverterForDataType(dataType).toExternal(deserializedRow); `
   in methed 
   `testField(
   			DataType fieldType,
   			String csvValue,
   			Object value,
   			Consumer<CsvRowDataDeserializationSchema.Builder> deserializationConfig,
   			String fieldDelimiter)`
   will change TIME(n) (0<=n<=3) to  TIME(0) .Then the test will fail.
    I still use `testFieldForTime()`.




----------------------------------------------------------------
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] [flink] wuchong commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514900466



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),

Review comment:
       For such case, I think you can use the test method only validate the deserialization.
   
   ```
   testField(
   			DataType fieldType,
   			String csvValue,
   			Object value,
   			Consumer<CsvRowDataDeserializationSchema.Builder> deserializationConfig,
   			String fieldDelimiter)
   ```




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][csv] Fix CSV format is unable to parse millisecond for TIME type

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8674",
       "triggerID" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741",
       "triggerID" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "triggerType" : "PUSH"
     }, {
       "hash" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485",
       "triggerID" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "triggerType" : "PUSH"
     }, {
       "hash" : "6dd7a167a257fe6379340600a53ab4262c35f62f",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9486",
       "triggerID" : "6dd7a167a257fe6379340600a53ab4262c35f62f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 6dd7a167a257fe6379340600a53ab4262c35f62f Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9486) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521302925



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       rename method  `testField(fieldType, csvValue, value, deserializationConfig, fieldDelimiter)` to `testFieldSerialization` ?or `testFieldDeserialization` ?




----------------------------------------------------------------
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] [flink] pyscala commented on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718683541


   CC @wuchong 


----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514941666



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),

Review comment:
       Sorry for my carelessness, I will optimize it.




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][csv] Fix CSV format is unable to parse millisecond for TIME type

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8674",
       "triggerID" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741",
       "triggerID" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "triggerType" : "PUSH"
     }, {
       "hash" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485",
       "triggerID" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "triggerType" : "PUSH"
     }, {
       "hash" : "6dd7a167a257fe6379340600a53ab4262c35f62f",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "6dd7a167a257fe6379340600a53ab4262c35f62f",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741) 
   * 63f6644db59a1a512ceef894317b3bf29355b7a0 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=9485) 
   * 6dd7a167a257fe6379340600a53ab4262c35f62f UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] wuchong commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514996865



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),

Review comment:
       This works in my environment:
   
   ```java
   		testField(
   			TIME(3),
   			"12:12:12.232421",
   			LocalTime.parse("12:12:12.232"),
   			(deserSchema) -> deserSchema.setNullLiteral("null"),
   			",");
   ```




----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514910288



##########
File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/RowDataToCsvConverters.java
##########
@@ -128,7 +128,7 @@ private static RowFieldConverter createRowFieldConverter(LogicalType fieldType)
 			case DATE:
 				return (csvMapper, container, row, pos) -> convertDate(row.getInt(pos), container);
 			case TIME_WITHOUT_TIME_ZONE:
-				return (csvMapper, container, row, pos) -> convertTime(row.getInt(pos), container);
+				return (csvMapper, container, row, pos) -> convertTime(row.getLong(pos), container);

Review comment:
       get it




----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521769804



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       done




----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521297859



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -320,6 +339,34 @@ private void testField(
 		assertEquals(expectedCsv, new String(serializedRow));
 	}
 
+	private void testFieldForTime(

Review comment:
       i will clean up

##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");
+		int precision = 5;
+		String expectedMessage = String.format("Csv does not support TIME type with precision: %d, it only supports precision 0 ~ 3.", precision);

Review comment:
       fix it




----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514886707



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),

Review comment:
       For example, the input is "12:12:12.232", but the precision is 2, then the result should be "12:12:12.23". The existing test named `testNullableField ` must be modified to meet the needs of this test. But the change affects other test cases. So i add a new test methed named `testFieldForTime`.




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8582",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8674",
       "triggerID" : "dfa6b28695625848a5798b38f7aa38b67029797a",
       "triggerType" : "PUSH"
     }, {
       "hash" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741",
       "triggerID" : "dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb",
       "triggerType" : "PUSH"
     }, {
       "hash" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "63f6644db59a1a512ceef894317b3bf29355b7a0",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * dc0a2a29d0fba59d7b7769353bd4d91aa1307ecb Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8741) 
   * 63f6644db59a1a512ceef894317b3bf29355b7a0 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] wuchong merged pull request #13834: [FLINK-19872][csv] Fix CSV format is unable to parse millisecond for TIME type

Posted by GitBox <gi...@apache.org>.
wuchong merged pull request #13834:
URL: https://github.com/apache/flink/pull/13834


   


----------------------------------------------------------------
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] [flink] wuchong commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514901214



##########
File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/RowDataToCsvConverters.java
##########
@@ -128,7 +128,7 @@ private static RowFieldConverter createRowFieldConverter(LogicalType fieldType)
 			case DATE:
 				return (csvMapper, container, row, pos) -> convertDate(row.getInt(pos), container);
 			case TIME_WITHOUT_TIME_ZONE:
-				return (csvMapper, container, row, pos) -> convertTime(row.getInt(pos), container);
+				return (csvMapper, container, row, pos) -> convertTime(row.getLong(pos), container);

Review comment:
       That's why we don't support `precision > 3` for now.
   When the planner supports `precision > 3` in the future, we can update csv format to use the higer precision data structure (maybe long or otheres). 
   




----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514885227



##########
File path: flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvToRowDataConverters.java
##########
@@ -221,12 +221,22 @@ private int convertToDate(JsonNode jsonNode) {
 		return (int) Date.valueOf(jsonNode.asText()).toLocalDate().toEpochDay();
 	}
 
-	private int convertToTime(JsonNode jsonNode) {
+	private CsvToRowDataConverter convertToTime(TimeType timeType) {
+		final int precision = timeType.getPrecision();
 		// csv currently is using Time.valueOf() to parse time string
-		LocalTime localTime = Time.valueOf(jsonNode.asText()).toLocalTime();
 		// TODO: FLINK-17525 support millisecond and nanosecond
 		// get number of milliseconds of the day
-		return localTime.toSecondOfDay() * 1000;
+		return jsonNode -> {
+			LocalTime localTime = LocalTime.parse(jsonNode.asText());
+			if (precision == 3) {
+				return localTime.toNanoOfDay() / 1000_000L;
+			} else if (precision == 0) {
+				return localTime.toSecondOfDay() * 1000L;
+			} else {
+				throw new IllegalArgumentException("Csv does not support TIME type " +
+					"with precision: " + precision + ", it only supports precision 0 or 3.");
+			}
+		};

Review comment:
       I will optimize.




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13834:
URL: https://github.com/apache/flink/pull/13834#issuecomment-718406146


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567",
       "triggerID" : "9a45aa49f38b831a4158debefa28f1443a21129c",
       "triggerType" : "PUSH"
     }, {
       "hash" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "3792d96b470ee584cd60265925bf578d65fffa64",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 9a45aa49f38b831a4158debefa28f1443a21129c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=8567) 
   * 3792d96b470ee584cd60265925bf578d65fffa64 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] pyscala commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
pyscala commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r514886707



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -109,6 +109,54 @@ public void testSerializeDeserialize() throws Exception {
 			new byte[] {107, 3, 11});
 	}
 
+	@Test
+	public void testSerializeDeserializeForTime() throws Exception {
+		testFieldForTime(
+			TIME(3),
+			"12:12:12.232",
+			"12:12:12.232",
+			(deserSchema) -> deserSchema.setNullLiteral("null"),
+			(serSchema) -> serSchema.setNullLiteral("null"),

Review comment:
       For example, the input is "12:12:!2.232", but the precision is 2, then the result should be "12:12:12.23". The existing test named `testNullableField ` must be modified to meet the needs of this test. But the change affects other test cases. So i add a new test methed named `testFieldForTime`.




----------------------------------------------------------------
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] [flink] wuchong commented on a change in pull request #13834: [FLINK-19872][Formats/Csv] Support to parse millisecond for TIME type in CSV format

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #13834:
URL: https://github.com/apache/flink/pull/13834#discussion_r521343815



##########
File path: flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
##########
@@ -150,6 +151,24 @@ public void testSerializeDeserializeCustomizedProperties() throws Exception {
 			deserConfig,
 			";");
 		testField(STRING(), "null", "null", serConfig, deserConfig, ";"); // string because null literal has not been set
+		testField(TIME(3), "12:12:12.232", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.232342", LocalTime.parse("12:12:12.232") , deserConfig , ";");
+		testField(TIME(3), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.23", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.232312", LocalTime.parse("12:12:12.23") , deserConfig , ";");
+		testField(TIME(2), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12.2235", LocalTime.parse("12:12:12.2") , deserConfig , ";");
+		testField(TIME(1), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12", LocalTime.parse("12:12:12") , deserConfig , ";");
+		testField(TIME(0), "12:12:12.45", LocalTime.parse("12:12:12") , deserConfig , ";");

Review comment:
       We only use `testNullableField` to test conversion without precision loss. 




----------------------------------------------------------------
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