diff --git a/app/data_client.go b/app/data_client.go index 9f2c48f6f85..6c5127dc3fb 100644 --- a/app/data_client.go +++ b/app/data_client.go @@ -318,6 +318,8 @@ type TabularDataByMQLOptions struct { // PipelineID is the ID of the pipeline to query. Required if TabularDataSourceType // is TabularDataSourceTypePipelineSink. PipelineID string + // QueryPrefixName specifies the name of the saved query to prepend to the provided MQL query. + QueryPrefixName string } // CreateDataPipelineOptions contains optional parameters for CreateDataPipeline. @@ -577,11 +579,17 @@ func (d *DataClient) TabularDataByMQL( } } - resp, err := d.dataClient.TabularDataByMQL(ctx, &pb.TabularDataByMQLRequest{ + req := &pb.TabularDataByMQLRequest{ OrganizationId: organizationID, MqlBinary: mqlBinary, DataSource: dataSource, - }) + } + + if opts.QueryPrefixName != "" { + req.QueryPrefixName = &opts.QueryPrefixName + } + + resp, err := d.dataClient.TabularDataByMQL(ctx, req) if err != nil { return nil, err } diff --git a/app/data_client_test.go b/app/data_client_test.go index 3ee781da79f..dd7b43dcba1 100644 --- a/app/data_client_test.go +++ b/app/data_client_test.go @@ -412,6 +412,7 @@ func TestDataClient(t *testing.T) { limitBytes, _ := bson.Marshal(limitQuery) mqlQueries := []map[string]interface{}{matchQuery, limitQuery} mqlBinary := [][]byte{matchBytes, limitBytes} + queryPrefixName := "prefix_name" // convert rawData to BSON var expectedRawDataPb [][]byte @@ -430,6 +431,9 @@ func TestDataClient(t *testing.T) { if in.DataSource != nil { test.That(t, in.DataSource.Type, test.ShouldNotEqual, pb.TabularDataSourceType_TABULAR_DATA_SOURCE_TYPE_UNSPECIFIED) } + if in.QueryPrefixName != nil { + test.That(t, *in.QueryPrefixName, test.ShouldEqual, queryPrefixName) + } return &pb.TabularDataByMQLResponse{ RawData: expectedRawDataPb, }, nil @@ -447,6 +451,11 @@ func TestDataClient(t *testing.T) { }) test.That(t, err, test.ShouldBeNil) test.That(t, response, test.ShouldResemble, rawData) + response, err = client.TabularDataByMQL(context.Background(), organizationID, mqlQueries, &TabularDataByMQLOptions{ + QueryPrefixName: queryPrefixName, + }) + test.That(t, err, test.ShouldBeNil) + test.That(t, response, test.ShouldResemble, rawData) }) t.Run("GetLatestTabularData", func(t *testing.T) {