Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: use dedicated timestamptz proto (#14001)
Danny Xue1adfb8b77ad
diff --git a/backend/plugin/db/cockroachdb/query.go b/backend/plugin/db/cockroachdb/query.goindex 2104641a93..3305f034d8 100644--- a/backend/plugin/db/cockroachdb/query.go+++ b/backend/plugin/db/cockroachdb/query.go@@ -82,8 +82,15 @@ func convertValue(typeName string, value any) *v1pb.RowValue {}case *sql.NullTime:if raw.Valid {+ zone, offset := raw.Time.Zone()return &v1pb.RowValue{- Kind: &v1pb.RowValue_TimestampValue{TimestampValue: timestamppb.New(raw.Time)},+ Kind: &v1pb.RowValue_TimestampTzValue{+ TimestampTzValue: &v1pb.RowValue_TimestampTZ{+ Timestamp: timestamppb.New(raw.Time),+ Zone: zone,+ Offset: int32(offset),+ },+ },}}}diff --git a/backend/plugin/db/dm/query.go b/backend/plugin/db/dm/query.goindex c18aca04c0..dd667307a2 100644--- a/backend/plugin/db/dm/query.go+++ b/backend/plugin/db/dm/query.go@@ -77,8 +77,15 @@ func convertValue(_ string, value any) *v1pb.RowValue {}case *sql.NullTime:if raw.Valid {+ zone, offset := raw.Time.Zone()return &v1pb.RowValue{- Kind: &v1pb.RowValue_TimestampValue{TimestampValue: timestamppb.New(raw.Time)},+ Kind: &v1pb.RowValue_TimestampTzValue{+ TimestampTzValue: &v1pb.RowValue_TimestampTZ{+ Timestamp: timestamppb.New(raw.Time),+ Zone: zone,+ Offset: int32(offset),+ },+ },}}}diff --git a/backend/plugin/db/mssql/query.go b/backend/plugin/db/mssql/query.goindex 6554f0c7b7..3f99ade6f0 100644--- a/backend/plugin/db/mssql/query.go+++ b/backend/plugin/db/mssql/query.go@@ -126,8 +126,15 @@ func convertValue(typeName string, value any) *v1pb.RowValue {}case *sql.NullTime:if raw.Valid {+ zone, offset := raw.Time.Zone()return &v1pb.RowValue{- Kind: &v1pb.RowValue_TimestampValue{TimestampValue: timestamppb.New(raw.Time)},+ Kind: &v1pb.RowValue_TimestampTzValue{+ TimestampTzValue: &v1pb.RowValue_TimestampTZ{+ Timestamp: timestamppb.New(raw.Time),+ Zone: zone,+ Offset: int32(offset),+ },+ },}}}diff --git a/backend/plugin/db/obo/query.go b/backend/plugin/db/obo/query.goindex 70fc49e7db..2d76aa3e83 100644--- a/backend/plugin/db/obo/query.go+++ b/backend/plugin/db/obo/query.go@@ -77,8 +77,15 @@ func convertValue(_ string, value any) *v1pb.RowValue {}case *sql.NullTime:if raw.Valid {+ zone, offset := raw.Time.Zone()return &v1pb.RowValue{- Kind: &v1pb.RowValue_TimestampValue{TimestampValue: timestamppb.New(raw.Time)},+ Kind: &v1pb.RowValue_TimestampTzValue{+ TimestampTzValue: &v1pb.RowValue_TimestampTZ{+ Timestamp: timestamppb.New(raw.Time),+ Zone: zone,+ Offset: int32(offset),+ },+ },}}}diff --git a/backend/plugin/db/oracle/query.go b/backend/plugin/db/oracle/query.goindex f0f00ff35b..4f412c5741 100644--- a/backend/plugin/db/oracle/query.go+++ b/backend/plugin/db/oracle/query.go@@ -88,8 +88,15 @@ func convertValue(_ string, value any) *v1pb.RowValue {}case *sql.NullTime:if raw.Valid {+ zone, offset := raw.Time.Zone()return &v1pb.RowValue{- Kind: &v1pb.RowValue_TimestampValue{TimestampValue: timestamppb.New(raw.Time)},+ Kind: &v1pb.RowValue_TimestampTzValue{+ TimestampTzValue: &v1pb.RowValue_TimestampTZ{+ Timestamp: timestamppb.New(raw.Time),+ Zone: zone,+ Offset: int32(offset),+ },+ },}}}diff --git a/backend/plugin/db/pg/query.go b/backend/plugin/db/pg/query.goindex 3117f88aa6..60997fb6b9 100644--- a/backend/plugin/db/pg/query.go+++ b/backend/plugin/db/pg/query.go@@ -82,8 +82,15 @@ func convertValue(typeName string, value any) *v1pb.RowValue {}case *sql.NullTime:if raw.Valid {+ zone, offset := raw.Time.Zone()return &v1pb.RowValue{- Kind: &v1pb.RowValue_TimestampValue{TimestampValue: timestamppb.New(raw.Time)},+ Kind: &v1pb.RowValue_TimestampTzValue{+ TimestampTzValue: &v1pb.RowValue_TimestampTZ{+ Timestamp: timestamppb.New(raw.Time),+ Zone: zone,+ Offset: int32(offset),+ },+ },}}}diff --git a/backend/plugin/db/redshift/query.go b/backend/plugin/db/redshift/query.goindex 1ff247adec..1b501b4e9b 100644--- a/backend/plugin/db/redshift/query.go+++ b/backend/plugin/db/redshift/query.go@@ -82,8 +82,15 @@ func convertValue(typeName string, value any) *v1pb.RowValue {}case *sql.NullTime:if raw.Valid {+ zone, offset := raw.Time.Zone()return &v1pb.RowValue{- Kind: &v1pb.RowValue_TimestampValue{TimestampValue: timestamppb.New(raw.Time)},+ Kind: &v1pb.RowValue_TimestampTzValue{+ TimestampTzValue: &v1pb.RowValue_TimestampTZ{+ Timestamp: timestamppb.New(raw.Time),+ Zone: zone,+ Offset: int32(offset),+ },+ },}}}diff --git a/backend/plugin/db/risingwave/query.go b/backend/plugin/db/risingwave/query.goindex dafc966c4f..f6b0a2a1e4 100644--- a/backend/plugin/db/risingwave/query.go+++ b/backend/plugin/db/risingwave/query.go@@ -82,8 +82,15 @@ func convertValue(typeName string, value any) *v1pb.RowValue {}case *sql.NullTime:if raw.Valid {+ zone, offset := raw.Time.Zone()return &v1pb.RowValue{- Kind: &v1pb.RowValue_TimestampValue{TimestampValue: timestamppb.New(raw.Time)},+ Kind: &v1pb.RowValue_TimestampTzValue{+ TimestampTzValue: &v1pb.RowValue_TimestampTZ{+ Timestamp: timestamppb.New(raw.Time),+ Zone: zone,+ Offset: int32(offset),+ },+ },}}}diff --git a/frontend/src/types/proto/v1/sql_service.ts b/frontend/src/types/proto/v1/sql_service.tsindex abd36c85d6..b142118d0d 100644--- a/frontend/src/types/proto/v1/sql_service.ts+++ b/frontend/src/types/proto/v1/sql_service.ts@@ -195,12 +195,15 @@ export interface RowValue_TimestampTZ {| Timestamp| undefined;/**- * Location is the TZ identifier name in timezone database such as "America/Los_Angeles".+ * Zone is the time zone abbreviations in timezone database such as "PDT", "PST".* https://en.wikipedia.org/wiki/List_of_tz_database_time_zones- * A timestamp is in UTC or epoch time, and with location info, we can convert it to a local time string.- * Avoid using UTC offsets or time zone abbreviations due to daylight saving changes.+ * We retrieve the time zone information from the timestamptz field in the database.+ * A timestamp is in UTC or epoch time, and with zone info, we can convert it to a local time string.+ * Zone and offset are returned by time.Time.Zone()*/- location: string;+ zone: string;+ /** The offset is in seconds east of UTC */+ offset: number;}export interface Advice {@@ -2063,7 +2066,7 @@ export const RowValue: MessageFns<RowValue> = {};function createBaseRowValue_TimestampTZ(): RowValue_TimestampTZ {- return { timestamp: undefined, location: "" };+ return { timestamp: undefined, zone: "", offset: 0 };}export const RowValue_TimestampTZ: MessageFns<RowValue_TimestampTZ> = {@@ -2071,8 +2074,11 @@ export const RowValue_TimestampTZ: MessageFns<RowValue_TimestampTZ> = {if (message.timestamp !== undefined) {Timestamp.encode(message.timestamp, writer.uint32(10).fork()).join();}- if (message.location !== "") {- writer.uint32(18).string(message.location);+ if (message.zone !== "") {+ writer.uint32(18).string(message.zone);+ }+ if (message.offset !== 0) {+ writer.uint32(24).int32(message.offset);}return writer;},@@ -2096,7 +2102,14 @@ export const RowValue_TimestampTZ: MessageFns<RowValue_TimestampTZ> = {break;}- message.location = reader.string();+ message.zone = reader.string();+ continue;+ case 3:+ if (tag !== 24) {+ break;+ }++ message.offset = reader.int32();continue;}if ((tag & 7) === 4 || tag === 0) {@@ -2110,7 +2123,8 @@ export const RowValue_TimestampTZ: MessageFns<RowValue_TimestampTZ> = {fromJSON(object: any): RowValue_TimestampTZ {return {timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,- location: isSet(object.location) ? globalThis.String(object.location) : "",+ zone: isSet(object.zone) ? globalThis.String(object.zone) : "",+ offset: isSet(object.offset) ? globalThis.Number(object.offset) : 0,};},@@ -2119,8 +2133,11 @@ export const RowValue_TimestampTZ: MessageFns<RowValue_TimestampTZ> = {if (message.timestamp !== undefined) {obj.timestamp = fromTimestamp(message.timestamp).toISOString();}- if (message.location !== "") {- obj.location = message.location;+ if (message.zone !== "") {+ obj.zone = message.zone;+ }+ if (message.offset !== 0) {+ obj.offset = Math.round(message.offset);}return obj;},@@ -2133,7 +2150,8 @@ export const RowValue_TimestampTZ: MessageFns<RowValue_TimestampTZ> = {message.timestamp = (object.timestamp !== undefined && object.timestamp !== null)? Timestamp.fromPartial(object.timestamp): undefined;- message.location = object.location ?? "";+ message.zone = object.zone ?? "";+ message.offset = object.offset ?? 0;return message;},};diff --git a/frontend/src/utils/v1/sql.ts b/frontend/src/utils/v1/sql.tsindex 32a9bba11a..e21e0c6ca8 100644--- a/frontend/src/utils/v1/sql.ts+++ b/frontend/src/utils/v1/sql.ts@@ -48,10 +48,9 @@ export const extractSQLRowValue = (raw: byteArray,};}- if (value.timestampValue) {- const timestampValue = value.timestampValue;- const fullDayjs = dayjs(getDateForPbTimestamp(timestampValue));- const microseconds = Math.floor(timestampValue.nanos / 1000);+ if (value.timestampTzValue && value.timestampTzValue.timestamp) {+ const fullDayjs = dayjs(getDateForPbTimestamp(value.timestampTzValue.timestamp));+ const microseconds = Math.floor(value.timestampTzValue.timestamp.nanos / 1000);let timezoneOffset = fullDayjs.format("Z");if (timezoneOffset.endsWith(":00")) {timezoneOffset = timezoneOffset.slice(0, -3);@@ -68,7 +67,7 @@ export const extractSQLRowValue = (return {plain: formattedTimestamp,- raw: timestampValue,+ raw: value.timestampTzValue,};}const key = keys[0];diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex 5ba3f5a588..7957d1e6f1 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -12480,13 +12480,18 @@ components:timestamp:type: stringformat: date-time- location:+ zone:type: stringdescription: |-- Location is the TZ identifier name in timezone database such as "America/Los_Angeles".+ Zone is the time zone abbreviations in timezone database such as "PDT", "PST".https://en.wikipedia.org/wiki/List_of_tz_database_time_zones- A timestamp is in UTC or epoch time, and with location info, we can convert it to a local time string.- Avoid using UTC offsets or time zone abbreviations due to daylight saving changes.+ We retrieve the time zone information from the timestamptz field in the database.+ A timestamp is in UTC or epoch time, and with zone info, we can convert it to a local time string.+ Zone and offset are returned by time.Time.Zone()+ offset:+ type: integer+ description: The offset is in seconds east of UTC+ format: int32RunPlanChecksRequest:required:- namediff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 0cd795b738..d0973a2ae2 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -10776,7 +10776,8 @@ for field description.| Field | Type | Label | Description || ----- | ---- | ----- | ----------- || timestamp | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |-| location | [string](#string) | | Location is the TZ identifier name in timezone database such as "America/Los_Angeles". https://en.wikipedia.org/wiki/List_of_tz_database_time_zones A timestamp is in UTC or epoch time, and with location info, we can convert it to a local time string. Avoid using UTC offsets or time zone abbreviations due to daylight saving changes. |+| zone | [string](#string) | | Zone is the time zone abbreviations in timezone database such as "PDT", "PST". https://en.wikipedia.org/wiki/List_of_tz_database_time_zones We retrieve the time zone information from the timestamptz field in the database. A timestamp is in UTC or epoch time, and with zone info, we can convert it to a local time string. Zone and offset are returned by time.Time.Zone() |+| offset | [int32](#int32) | | The offset is in seconds east of UTC |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex b31db08a64..0a5cd32022 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -29382,13 +29382,21 @@ Although it may be expressed as a UTC value, it should be seen as a timestamp mi</tr><tr>- <td>location</td>+ <td>zone</td><td><a href="#string">string</a></td><td></td>- <td><p>Location is the TZ identifier name in timezone database such as "America/Los_Angeles".+ <td><p>Zone is the time zone abbreviations in timezone database such as "PDT", "PST".https://en.wikipedia.org/wiki/List_of_tz_database_time_zones-A timestamp is in UTC or epoch time, and with location info, we can convert it to a local time string.-Avoid using UTC offsets or time zone abbreviations due to daylight saving changes. </p></td>+We retrieve the time zone information from the timestamptz field in the database.+A timestamp is in UTC or epoch time, and with zone info, we can convert it to a local time string.+Zone and offset are returned by time.Time.Zone() </p></td>+ </tr>++ <tr>+ <td>offset</td>+ <td><a href="#int32">int32</a></td>+ <td></td>+ <td><p>The offset is in seconds east of UTC </p></td></tr></tbody>diff --git a/proto/generated-go/v1/sql_service.pb.go b/proto/generated-go/v1/sql_service.pb.goindex 2dd89c2b64..903a38f687 100644--- a/proto/generated-go/v1/sql_service.pb.go+++ b/proto/generated-go/v1/sql_service.pb.go@@ -2334,11 +2334,14 @@ type RowValue_TimestampTZ struct {unknownFields protoimpl.UnknownFieldsTimestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`- // Location is the TZ identifier name in timezone database such as "America/Los_Angeles".+ // Zone is the time zone abbreviations in timezone database such as "PDT", "PST".// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones- // A timestamp is in UTC or epoch time, and with location info, we can convert it to a local time string.- // Avoid using UTC offsets or time zone abbreviations due to daylight saving changes.- Location string `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"`+ // We retrieve the time zone information from the timestamptz field in the database.+ // A timestamp is in UTC or epoch time, and with zone info, we can convert it to a local time string.+ // Zone and offset are returned by time.Time.Zone()+ Zone string `protobuf:"bytes,2,opt,name=zone,proto3" json:"zone,omitempty"`+ // The offset is in seconds east of UTC+ Offset int32 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"`}func (x *RowValue_TimestampTZ) Reset() {@@ -2380,13 +2383,20 @@ func (x *RowValue_TimestampTZ) GetTimestamp() *timestamppb.Timestamp {return nil}-func (x *RowValue_TimestampTZ) GetLocation() string {+func (x *RowValue_TimestampTZ) GetZone() string {if x != nil {- return x.Location+ return x.Zone}return ""}+func (x *RowValue_TimestampTZ) GetOffset() int32 {+ if x != nil {+ return x.Offset+ }+ return 0+}+var File_v1_sql_service_proto protoreflect.FileDescriptorvar file_v1_sql_service_proto_rawDesc = []byte{@@ -2536,7 +2546,7 @@ var file_v1_sql_service_proto_rawDesc = []byte{0x75, 0x65, 0x72, 0x79, 0x52, 0x6f, 0x77, 0x12, 0x2d, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65,0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x6f, 0x77, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06,- 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0xca, 0x05, 0x0a, 0x08, 0x52, 0x6f, 0x77, 0x56, 0x61,+ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0xda, 0x05, 0x0a, 0x08, 0x52, 0x6f, 0x77, 0x56, 0x61,0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75,0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x56, 0x61,@@ -2574,13 +2584,14 @@ var file_v1_sql_service_proto_rawDesc = []byte{0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x6f,0x77, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,0x54, 0x5a, 0x48, 0x00, 0x52, 0x10, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x54,- 0x7a, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x63, 0x0a, 0x0b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74,+ 0x7a, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x73, 0x0a, 0x0b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74,0x61, 0x6d, 0x70, 0x54, 0x5a, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73,0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12,- 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x06, 0x0a, 0x04, 0x6b,+ 0x12, 0x0a, 0x04, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x7a,+ 0x6f, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20,+ 0x01, 0x28, 0x05, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x6b,0x69, 0x6e, 0x64, 0x22, 0x83, 0x03, 0x0a, 0x06, 0x41, 0x64, 0x76, 0x69, 0x63, 0x65, 0x12, 0x32,0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a,0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x76,diff --git a/proto/v1/sql_service.proto b/proto/v1/sql_service.protoindex 65d36191a8..71ff627c05 100644--- a/proto/v1/sql_service.proto+++ b/proto/v1/sql_service.proto@@ -279,11 +279,14 @@ message QueryRow {message RowValue {message TimestampTZ {google.protobuf.Timestamp timestamp = 1;- // Location is the TZ identifier name in timezone database such as "America/Los_Angeles".+ // Zone is the time zone abbreviations in timezone database such as "PDT", "PST".// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones- // A timestamp is in UTC or epoch time, and with location info, we can convert it to a local time string.- // Avoid using UTC offsets or time zone abbreviations due to daylight saving changes.- string location = 2;+ // We retrieve the time zone information from the timestamptz field in the database.+ // A timestamp is in UTC or epoch time, and with zone info, we can convert it to a local time string.+ // Zone and offset are returned by time.Time.Zone()+ string zone = 2;+ // The offset is in seconds east of UTC+ int32 offset = 3;}oneof kind {