Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yittg committed Sep 14, 2021
1 parent 68074dc commit fd278a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/content.zh/docs/connectors/table/datagen.md
Expand Up @@ -129,7 +129,7 @@ CREATE TABLE datagen (
<td>可选</td>
<td style="word-wrap: break-word;">0</td>
<td>Duration</td>
<td>随机生成器生成相对当前时间向过去偏移的最大值,适用于 Timestamp 类型.</td>
<td>随机生成器生成相对当前时间向过去偏移的最大值,适用于 timestamp 类型</td>
</tr>
<tr>
<td><h5>fields.#.length</h5></td>
Expand Down
6 changes: 3 additions & 3 deletions docs/content/docs/connectors/table/datagen.md
Expand Up @@ -159,15 +159,15 @@ Types
<td>random</td>
<td>
Resolves a past timestamp relative to the current timestamp of the local machine.
The max past is specified by the 'max-past' option.
The max past can be specified by the 'max-past' option.
</td>
</tr>
<tr>
<td>TIMESTAMP_LTZ</td>
<td>random</td>
<td>
Resolves a past timestamp relative to the current timestamp of the local machine.
The max past is specified by the 'max-past' option.
The max past can be specified by the 'max-past' option.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -264,7 +264,7 @@ Connector Options
<td>optional</td>
<td style="word-wrap: break-word;">0</td>
<td>Duration</td>
<td>Maximum past of timestamp random generator, work for timestamp types.</td>
<td>Maximum past of timestamp random generator, only works for timestamp types.</td>
</tr>
<tr>
<td><h5>fields.#.length</h5></td>
Expand Down
Expand Up @@ -24,13 +24,9 @@
import org.apache.flink.runtime.state.FunctionInitializationContext;
import org.apache.flink.streaming.api.functions.source.datagen.DataGenerator;
import org.apache.flink.table.api.ValidationException;
import org.apache.flink.table.data.TimestampData;
import org.apache.flink.table.types.logical.DateType;
import org.apache.flink.table.types.logical.LocalZonedTimestampType;
import org.apache.flink.table.types.logical.LogicalType;
import org.apache.flink.table.types.logical.TimeType;
import org.apache.flink.table.types.logical.TimestampType;
import org.apache.flink.table.types.logical.ZonedTimestampType;
import org.apache.flink.table.types.logical.utils.LogicalTypeDefaultVisitor;

import java.io.Serializable;
Expand Down Expand Up @@ -66,24 +62,6 @@ public DataGeneratorContainer visit(TimeType timeType) {
return DataGeneratorContainer.of(TimeGenerator.of(() -> LocalTime.now().get(MILLI_OF_DAY)));
}

@Override
public DataGeneratorContainer visit(TimestampType timestampType) {
return DataGeneratorContainer.of(
TimeGenerator.of(() -> TimestampData.fromEpochMillis(System.currentTimeMillis())));
}

@Override
public DataGeneratorContainer visit(ZonedTimestampType zonedTimestampType) {
return DataGeneratorContainer.of(
TimeGenerator.of(() -> TimestampData.fromEpochMillis(System.currentTimeMillis())));
}

@Override
public DataGeneratorContainer visit(LocalZonedTimestampType localZonedTimestampType) {
return DataGeneratorContainer.of(
TimeGenerator.of(() -> TimestampData.fromEpochMillis(System.currentTimeMillis())));
}

@Override
protected DataGeneratorContainer defaultMethod(LogicalType logicalType) {
throw new ValidationException("Unsupported type: " + logicalType);
Expand Down

0 comments on commit fd278a5

Please sign in to comment.