Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bigquery): do not send preview field and rows if max_preview_rows is -1 #46

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 16 additions & 10 deletions plugins/extractors/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,21 @@ func (e *Extractor) buildAsset(ctx context.Context, t *bigquery.Table, md *bigqu
}
}

table, err := anypb.New(&v1beta2.Table{
Columns: e.buildColumns(ctx, md.Schema, md),
PreviewFields: previewFields,
PreviewRows: previewRows,
Profile: tableProfile,
Attributes: utils.TryParseMapToProto(attributesData),
CreateTime: timestamppb.New(md.CreationTime),
UpdateTime: timestamppb.New(md.LastModifiedTime),
})
tableData := &v1beta2.Table{
Columns: e.buildColumns(ctx, md.Schema, md),
Profile: tableProfile,
Attributes: utils.TryParseMapToProto(attributesData),
CreateTime: timestamppb.New(md.CreationTime),
UpdateTime: timestamppb.New(md.LastModifiedTime),
}

maxPreviewRows := e.config.MaxPreviewRows
if maxPreviewRows != -1 {
bsushmith marked this conversation as resolved.
Show resolved Hide resolved
tableData.PreviewFields = previewFields
tableData.PreviewRows = previewRows
}

table, err := anypb.New(tableData)
if err != nil {
e.logger.Warn("error creating Any struct", "error", err)
}
Expand Down Expand Up @@ -515,7 +521,7 @@ func (e *Extractor) buildColumn(ctx context.Context, field *bigquery.FieldSchema

func (e *Extractor) buildPreview(ctx context.Context, t *bigquery.Table, md *bigquery.TableMetadata) (fields []string, rows *structpb.ListValue, err error) {
maxPreviewRows := e.config.MaxPreviewRows
if maxPreviewRows == 0 {
if maxPreviewRows == 0 || maxPreviewRows == -1 {
bsushmith marked this conversation as resolved.
Show resolved Hide resolved
return nil, nil, nil
}

Expand Down
9 changes: 5 additions & 4 deletions plugins/sinks/compass/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import (
var summary string

type Config struct {
Host string `mapstructure:"host" validate:"required"`
Headers map[string]string `mapstructure:"headers"`
Labels map[string]string `mapstructure:"labels"`
Host string `mapstructure:"host" validate:"required"`
Headers map[string]string `mapstructure:"headers"`
Labels map[string]string `mapstructure:"labels"`
RemoveUnsetFields bool `mapstructure:"remove_unset_fields" default:"false"`
bsushmith marked this conversation as resolved.
Show resolved Hide resolved
}

var info = plugins.Info{
Expand Down Expand Up @@ -193,7 +194,7 @@ func (s *Sink) buildCompassData(anyData *anypb.Any) (map[string]interface{}, err

data, err := protojson.MarshalOptions{
UseProtoNames: true,
EmitUnpopulated: true,
EmitUnpopulated: !s.config.RemoveUnsetFields,
}.Marshal(anyData)
if err != nil {
return nil, fmt.Errorf("marshaling asset data: %w", err)
Expand Down
Loading