Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions app/data_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions app/data_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand Down
Loading