Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Optimization-3861] Display the timestamp type field as a string value when previewing data #4194

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import org.apache.flink.types.RowKind;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -57,6 +59,7 @@ public class ResultRunnable implements Runnable {
private final boolean isAutoCancel;
private final String timeZone;
private BiConsumer<String, SelectResult> callback;
private static final DateTimeFormatter FORMATTER_CACHE = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

public ResultRunnable(
TableResult tableResult,
Expand Down Expand Up @@ -164,9 +167,11 @@ private Map<String, Object> getFieldMap(List<String> columns, Row row) {
((Instant) field)
.atZone(ZoneId.of(timeZone))
.toLocalDateTime()
.toString());
.format(FORMATTER_CACHE));
} else if (field instanceof Boolean) {
map.put(column, field.toString());
} else if (field instanceof LocalDateTime) {
map.put(column, ((LocalDateTime) field).format(FORMATTER_CACHE));
} else {
map.put(column, field);
}
Expand Down
Loading