diff --git a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt index 80b6530af1e..e861d66cbd3 100644 --- a/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt +++ b/src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ProtoConversions.kt @@ -635,7 +635,7 @@ fun InternalReport.ReportingMetric.toCreateMetricRequest( metricSpec = source.details.metricSpec.toMetricSpec() filters += source.details.filtersList } - requestId = source.requestId + requestId = source.createMetricRequestId } } diff --git a/src/main/proto/wfa/measurement/internal/reporting/v2/report.proto b/src/main/proto/wfa/measurement/internal/reporting/v2/report.proto index 3ea5c0468e3..e8cdbcdfd44 100644 --- a/src/main/proto/wfa/measurement/internal/reporting/v2/report.proto +++ b/src/main/proto/wfa/measurement/internal/reporting/v2/report.proto @@ -32,11 +32,18 @@ message Report { google.protobuf.Timestamp create_time = 3; message ReportingMetric { - // Will be filled by the internal reports service. For now, generating a new - // UUID. In the future when metric reuse is done. Two cases--(1) When there - // is no metric can be found based on the metric config from 3-6, generate a - // new UUID. (2) When a corresponding metric is found, fill its request ID. - string request_id = 1; + // Request ID for the CreateMetric method. + // + // The request ID will be filled by the internal reports service. For now, + // it generates a new UUID directly. + // In the future when metric reuse is done, two cases--(1) When there is no + // metric can be found based on the metric config, generate a new UUID. (2) + // When a corresponding metric is found, fill its request ID and the + // external metric ID. + string create_metric_request_id = 1; + + // External ID for the metric. + // // Will be filled by the internal reports service. Use the request ID above // to find the metric. fixed64 external_metric_id = 2; diff --git a/src/main/resources/reporting/postgres/create-v2-reporting-schema.sql b/src/main/resources/reporting/postgres/create-v2-reporting-schema.sql index e683189177e..c45ab302fd3 100644 --- a/src/main/resources/reporting/postgres/create-v2-reporting-schema.sql +++ b/src/main/resources/reporting/postgres/create-v2-reporting-schema.sql @@ -177,7 +177,7 @@ CREATE TABLE SetExpressions ( ReportingSetId bigint NOT NULL, SetExpressionId bigint NOT NULL, - -- org.wfanet.measurement.internal.reporting.SetExpression.Operation + -- wfa.measurement.internal.reporting.SetExpression.Operation -- protobuf enum encoded as an integer. Operation integer NOT NULL, @@ -227,7 +227,7 @@ CREATE TABLE Metrics ( TimeIntervalStart TIMESTAMP WITH TIME ZONE NOT NULL, TimeIntervalEndExclusive TIMESTAMP WITH TIME ZONE NOT NULL, - -- org.wfanet.measurement.internal.reporting.MetricSpec.MetricType + -- wfa.measurement.internal.reporting.MetricSpec.MetricType -- protobuf oneof encoded as an integer. MetricType integer NOT NULL, @@ -251,7 +251,7 @@ CREATE TABLE Metrics ( -- Serialized byte string of a proto3 protobuf with details about the -- metric which do not need to be indexed by the database. -- - -- See org.wfanet.measurement.internal.reporting.Metric.Details protobuf + -- See wfa.measurement.internal.reporting.Metric.Details protobuf -- message. MetricDetails bytea NOT NULL, @@ -277,14 +277,14 @@ CREATE TABLE Measurements ( TimeIntervalStart TIMESTAMP WITH TIME ZONE NOT NULL, TimeIntervalEndExclusive TIMESTAMP WITH TIME ZONE NOT NULL, - -- org.wfanet.measurement.internal.reporting.Report.Measurement.State + -- wfa.measurement.internal.reporting.Report.Measurement.State -- protobuf enum encoded as an integer. State integer NOT NULL, -- Serialized byte string of a proto3 protobuf with details about the -- measurement which do not need to be indexed by the database. -- - -- See org.wfanet.measurement.internal.reporting.Measurement.Details protobuf + -- See wfa.measurement.internal.reporting.Measurement.Details protobuf -- message. MeasurementDetails bytea NOT NULL, @@ -359,7 +359,7 @@ CREATE TABLE ReportTimeIntervals ( ON DELETE CASCADE ); --- changeset riemanli:create-metric-calculations-table dbms:postgresql +-- changeset riemanli:create-metric-calculation-specs-table dbms:postgresql CREATE TABLE MetricCalculationSpecs ( MeasurementConsumerId bigint NOT NULL, ReportId bigint NOT NULL, @@ -369,7 +369,7 @@ CREATE TABLE MetricCalculationSpecs ( -- Serialized byte string of a proto3 protobuf with details about the -- metric calculation which do not need to be indexed by the database. -- - -- See org.wfanet.measurement.internal.reporting.Report.MetricCalculationSpec.Details + -- See wfa.measurement.internal.reporting.Report.MetricCalculationSpec.Details -- protobuf message. MetricCalculationSpecDetails bytea NOT NULL, @@ -386,24 +386,24 @@ CREATE TABLE MetricCalculationSpecs ( ON DELETE CASCADE ); --- changeset riemanli:create-metric-calculation-metrics-table dbms:postgresql -CREATE TABLE MetricCalculationSpecMetrics ( +-- changeset riemanli:create-metric-calculation-spec-reporting-metrics-table dbms:postgresql +CREATE TABLE MetricCalculationSpecReportingMetrics ( MeasurementConsumerId bigint NOT NULL, ReportId bigint NOT NULL, MetricCalculationSpecId bigint NOT NULL, - MetricId bigint, CreateMetricRequestId uuid NOT NULL, + MetricId bigint, -- Serialized byte string of a proto3 protobuf with details about the - -- Report.CreateMetricRequest which do not need to be indexed by the database. + -- Report.ReportingMetric which do not need to be indexed by the database. -- - -- See org.wfanet.measurement.internal.reporting.Report.CreateMetricRequest.Details + -- See wfa.measurement.internal.reporting.Report.ReportingMetric.Details -- protobuf message. - CreateMetricRequestDetails bytea NOT NULL, + ReportingMetricDetails bytea NOT NULL, - -- Human-readable copy of the CreateMetricRequestDetails column solely for + -- Human-readable copy of the ReportingMetricDetails column solely for -- debugging purposes. - CreateMetricRequestDetailsJson text NOT NULL, + ReportingMetricDetailsJson text NOT NULL, PRIMARY KEY(MeasurementConsumerId, ReportId, MetricCalculationSpecId, CreateMetricRequestId), FOREIGN KEY(MeasurementConsumerId, ReportId, MetricCalculationSpecId) diff --git a/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsServiceTest.kt b/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsServiceTest.kt index c6efad1e1de..cfb37534d93 100644 --- a/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsServiceTest.kt +++ b/src/test/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha/ReportsServiceTest.kt @@ -713,7 +713,7 @@ class ReportsServiceTest { var requestId = 0 reportingSetToCreateMetricRequestMap.map { (reportingSet, createMetricRequest) -> val updatedReportingCreateMetricRequests = - listOf(createMetricRequest.copy { this.requestId = requestId.toString() }) + listOf(createMetricRequest.copy { this.createMetricRequestId = requestId.toString() }) requestId++ reportingMetricEntries.putAll( buildInternalReportingMetricEntryWithOneMetricCalculationSpec( @@ -736,7 +736,7 @@ class ReportsServiceTest { val updatedReportingCreateMetricRequests = listOf( createMetricRequest.copy { - this.requestId = requestId.toString() + this.createMetricRequestId = requestId.toString() externalMetricId = EXTERNAL_METRIC_ID_BASE + requestId } ) @@ -910,7 +910,7 @@ class ReportsServiceTest { internalMetricCalculationSpec.copy { val updatedReportingMetrics = reportingMetrics.map { reportingMetric -> - reportingMetric.copy { this.requestId = requestId.toString() } + reportingMetric.copy { this.createMetricRequestId = requestId.toString() } } this.reportingMetrics.clear() this.reportingMetrics += updatedReportingMetrics @@ -934,7 +934,7 @@ class ReportsServiceTest { val updatedReportingMetrics = reportingMetrics.map { reportingMetric -> reportingMetric.copy { - this.requestId = requestId.toString() + this.createMetricRequestId = requestId.toString() externalMetricId = EXTERNAL_METRIC_ID_BASE + requestId } } @@ -1111,7 +1111,7 @@ class ReportsServiceTest { val updatedReportingCreateMetricRequests = reportingCreateMetricRequests.mapIndexed { requestId, request -> - request.copy { this.requestId = requestId.toString() } + request.copy { this.createMetricRequestId = requestId.toString() } } reportingMetricEntries.putAll( @@ -1130,7 +1130,7 @@ class ReportsServiceTest { val updatedReportingCreateMetricRequests = reportingCreateMetricRequests.mapIndexed { requestId, request -> request.copy { - this.requestId = requestId.toString() + this.createMetricRequestId = requestId.toString() externalMetricId = EXTERNAL_METRIC_ID_BASE + requestId } } @@ -1985,7 +1985,7 @@ class ReportsServiceTest { val reportingCreateMetricRequests = reportingMetrics.mapIndexed { requestId, request -> - request.copy { this.requestId = requestId.toString() } + request.copy { this.createMetricRequestId = requestId.toString() } } reportingMetricEntries.putAll( @@ -2003,7 +2003,7 @@ class ReportsServiceTest { val reportingCreateMetricRequests = reportingMetrics.mapIndexed { requestId, request -> request.copy { - this.requestId = requestId.toString() + this.createMetricRequestId = requestId.toString() externalMetricId = EXTERNAL_METRIC_ID_BASE + requestId } }