wuchong commented on a change in pull request #12661:
URL: https://github.com/apache/flink/pull/12661#discussion_r440777286
##########
File path:
flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDataSerDeSchemaTest.java
##########
@@ -383,73 +407,117 @@ private void testParseErrors(TestSpec spec) throws
Exception {
TestSpec
.json("{\"id\": \"trueA\"}")
.rowType(ROW(FIELD("id", BOOLEAN())))
+ .timestampFormat("ISO-8601")
Review comment:
You can make the timestampFormat as optional to avoid invoke it for
every TestSpec.
##########
File path:
flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonFormatFactoryTest.java
##########
@@ -91,6 +91,16 @@ public void testInvalidOptionForIgnoreParseErrors() {
testSchemaDeserializationSchema(tableOptions);
}
+ @Test
+ public void testInvalidOptionForTimestampFormat() {
+ final Map<String, String> tableOptions = getModifyOptions(
+ options ->
options.put("json.timestamp-format.standard", "test"));
+
+ thrown.expect(ValidationException.class);
+ thrown.expect(containsCause(new
ValidationException("Unsupported value test for timestamp-format.standard.
Supported values are [SQL, ISO-8601].")));
Review comment:
```suggestion
thrown.expect(containsCause(new
ValidationException("Unsupported value 'test' for timestamp-format.standard.
Supported values are [SQL, ISO-8601].")));
```
##########
File path:
flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDataSerDeSchemaTest.java
##########
@@ -168,7 +168,7 @@ public void testSerDe() throws Exception {
assertEquals(expected, actual);
// test serialization
- JsonRowDataSerializationSchema serializationSchema = new
JsonRowDataSerializationSchema(schema);
+ JsonRowDataSerializationSchema serializationSchema = new
JsonRowDataSerializationSchema(schema,
JsonOptions.getTimestampFormatOption("ISO-8601"));
Review comment:
TimestampFormat.ISO_8601
##########
File path: docs/dev/table/connectors/formats/json.md
##########
@@ -103,6 +103,18 @@ Format Options
<td>Skip fields and rows with parse errors instead of failing.
Fields are set to null in case of errors.</td>
</tr>
+ <tr>
+ <td><h5>json.timestamp-format.standard</h5></td>
+ <td>optional</td>
+ <td style="word-wrap: break-word;"><code>'SQL'</code></td>
+ <td>String</td>
+ <td>Specify the input and output timestamp format. Currently supported
values are <code>'SQL'</code> and <code>'ISO-8601'</code>:
+ <ul>
+ <li>Option <code>'SQL'</code> will parse input timestamp in
"yyyy-MM-dd HH:mm:ss.s{precision}" format, e.g '2020-12-30 12:13:14.123' and
output timestamp in the same way.</li>
+ <li>Option <code>'ISO-8601'</code>will parse input timestamp in
"yyyy-MM-ddTHH:mm:ss.s{precision}" format, e.g '2020-12-30T12:13:14.123' and
output timestamp in the same way.</li>
Review comment:
```suggestion
<li>Option <code>'ISO-8601'</code>will parse input timestamp in
"yyyy-MM-ddTHH:mm:ss.s{precision}" format, e.g '2020-12-30T12:13:14.123' and
output timestamp in the same format.</li>
```
----------------------------------------------------------------
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:
[email protected]