2121package com .dtstack .flink .sql .table ;
2222
2323import org .apache .flink .calcite .shaded .com .google .common .base .Strings ;
24+ import org .apache .flink .calcite .shaded .com .google .common .collect .Lists ;
2425import org .apache .flink .calcite .shaded .com .google .common .collect .Maps ;
26+ import org .apache .flink .util .StringUtils ;
2527
28+ import java .util .ArrayList ;
2629import java .util .Map ;
30+ import java .util .TimeZone ;
2731
2832/**
2933 * Reason:
@@ -36,6 +40,10 @@ public abstract class SourceTableInfo extends TableInfo {
3640
3741 public static final String SOURCE_SUFFIX = "Source" ;
3842
43+ public static final String TIME_ZONE_KEY ="timezone" ;
44+
45+ private String timeZone =TimeZone .getDefault ().getID ();
46+
3947 private String eventTimeField ;
4048
4149 private Integer maxOutOrderness = 10 ;
@@ -63,7 +71,6 @@ public void setMaxOutOrderness(Integer maxOutOrderness) {
6371 if (maxOutOrderness == null ){
6472 return ;
6573 }
66-
6774 this .maxOutOrderness = maxOutOrderness ;
6875 }
6976
@@ -101,4 +108,23 @@ public String getAdaptSelectSql(){
101108 public String getAdaptName (){
102109 return getName () + "_adapt" ;
103110 }
111+
112+ public String getTimeZone () {
113+ return timeZone ;
114+ }
115+
116+ public void setTimeZone (String timeZone ) {
117+ if (StringUtils .isNullOrWhitespaceOnly (timeZone )){
118+ return ;
119+ }
120+ timeZoneCheck (timeZone );
121+ this .timeZone = timeZone ;
122+ }
123+
124+ private void timeZoneCheck (String timeZone ) {
125+ ArrayList <String > zones = Lists .newArrayList (TimeZone .getAvailableIDs ());
126+ if (!zones .contains (timeZone )){
127+ throw new IllegalArgumentException (" timezone is Incorrect!" );
128+ }
129+ }
104130}
0 commit comments