Skip to content

Commit

Permalink
add storage compression type to collection (#95)
Browse files Browse the repository at this point in the history
* add storage compression type to collection

* fix

* docs

* update rockset go client

* format

* address comment
  • Loading branch information
kristielim authored Mar 13, 2024
1 parent 3a19605 commit acfc941
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 43 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
- checkout
- run:
name: Terraform Acceptance Tests
no_output_timeout: 40m
command: go test -race -cover -coverprofile=$HOME/cover.out -timeout 40m -v ./rockset/*
environment:
TF_ACC: true
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ To run a specific test:
TF_ACC=true go test -timeout 40m -v ./rockset/* -run TestAccS3Collection_Basic
```

You may want to run tests with local changes in a dependency, such as in the [Rockset Go Client](https://github.com/rockset/rockset-go-client). (For example, you may be adding a field in both the Rockset Go client and the Terraform Provider) Use the `replace` keyword in the `go.mod` file to use the local version of the dependency instead.
```
module github.com/rockset/terraform-provider-rockset
replace github.com/rockset/rockset-go-client => ../rockset-go-client
```

### Pre-commit hooks

The repo comes with a `.pre-commit-config.yaml` file which can be enabled using `pre-commit install`,
Expand Down
1 change: 1 addition & 0 deletions docs/resources/collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This is referred to as the collection’s ingest transformation or, historically

For more information see https://rockset.com/docs/ingest-transformation/
- `retention_secs` (Number) Number of seconds after which data is purged. Based on event time.
- `storage_compression_type` (String) RocksDB storage compression type. Possible values: ZSTD, LZ4.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `wait_for_collection` (Boolean) Wait until the collection is ready.
- `wait_for_documents` (Number) Wait until the collection has documents. The default is to wait for 0 documents, which means it doesn't wait.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/dynamodb_collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This is referred to as the collection’s ingest transformation or, historically
For more information see https://rockset.com/docs/ingest-transformation/
- `retention_secs` (Number) Number of seconds after which data is purged. Based on event time.
- `source` (Block Set) Defines a source for this collection. (see [below for nested schema](#nestedblock--source))
- `storage_compression_type` (String) RocksDB storage compression type. Possible values: ZSTD, LZ4.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `wait_for_collection` (Boolean) Wait until the collection is ready.
- `wait_for_documents` (Number) Wait until the collection has documents. The default is to wait for 0 documents, which means it doesn't wait.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/gcs_collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This is referred to as the collection’s ingest transformation or, historically
For more information see https://rockset.com/docs/ingest-transformation/
- `retention_secs` (Number) Number of seconds after which data is purged. Based on event time.
- `source` (Block Set) Defines a source for this collection. (see [below for nested schema](#nestedblock--source))
- `storage_compression_type` (String) RocksDB storage compression type. Possible values: ZSTD, LZ4.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `wait_for_collection` (Boolean) Wait until the collection is ready.
- `wait_for_documents` (Number) Wait until the collection has documents. The default is to wait for 0 documents, which means it doesn't wait.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/kafka_collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ This is referred to as the collection’s ingest transformation or, historically
For more information see https://rockset.com/docs/ingest-transformation/
- `retention_secs` (Number) Number of seconds after which data is purged. Based on event time.
- `source` (Block Set) Defines a source for this collection. (see [below for nested schema](#nestedblock--source))
- `storage_compression_type` (String) RocksDB storage compression type. Possible values: ZSTD, LZ4.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `wait_for_collection` (Boolean) Wait until the collection is ready.
- `wait_for_documents` (Number) Wait until the collection has documents. The default is to wait for 0 documents, which means it doesn't wait.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/kinesis_collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This is referred to as the collection’s ingest transformation or, historically
For more information see https://rockset.com/docs/ingest-transformation/
- `retention_secs` (Number) Number of seconds after which data is purged. Based on event time.
- `source` (Block Set) Defines a source for this collection. (see [below for nested schema](#nestedblock--source))
- `storage_compression_type` (String) RocksDB storage compression type. Possible values: ZSTD, LZ4.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `wait_for_collection` (Boolean) Wait until the collection is ready.
- `wait_for_documents` (Number) Wait until the collection has documents. The default is to wait for 0 documents, which means it doesn't wait.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/mongodb_collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This is referred to as the collection’s ingest transformation or, historically
For more information see https://rockset.com/docs/ingest-transformation/
- `retention_secs` (Number) Number of seconds after which data is purged. Based on event time.
- `source` (Block Set) Defines a source for this collection. (see [below for nested schema](#nestedblock--source))
- `storage_compression_type` (String) RocksDB storage compression type. Possible values: ZSTD, LZ4.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `wait_for_collection` (Boolean) Wait until the collection is ready.
- `wait_for_documents` (Number) Wait until the collection has documents. The default is to wait for 0 documents, which means it doesn't wait.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/s3_collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ This is referred to as the collection’s ingest transformation or, historically
For more information see https://rockset.com/docs/ingest-transformation/
- `retention_secs` (Number) Number of seconds after which data is purged. Based on event time.
- `source` (Block Set) Defines a source for this collection. (see [below for nested schema](#nestedblock--source))
- `storage_compression_type` (String) RocksDB storage compression type. Possible values: ZSTD, LZ4.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `wait_for_collection` (Boolean) Wait until the collection is ready.
- `wait_for_documents` (Number) Wait until the collection has documents. The default is to wait for 0 documents, which means it doesn't wait.
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/rockset/rockset-go-client v0.23.0
github.com/rockset/rockset-go-client v0.24.1
github.com/rs/zerolog v1.32.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
)

require (
Expand Down Expand Up @@ -50,12 +50,12 @@ require (
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rockset/rockset-go-client v0.23.0 h1:KOvRp93Zal+HL8xPL6s+1wTj0EsXURdqBQqffdhh/Q8=
github.com/rockset/rockset-go-client v0.23.0/go.mod h1:rydfdrQAcvc50SMLZRq3frf+2i9rx9ZDPXcju1tyhWA=
github.com/rockset/rockset-go-client v0.24.1 h1:s8LpCAso5Bqh/3UEJgOYLry615jiQjc0ajInQBL5XoQ=
github.com/rockset/rockset-go-client v0.24.1/go.mod h1:Q5mjXK/azJa+CM/+cFEnZOfxvYw2I7S3fOXLKpJFSGA=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
Expand All @@ -246,8 +246,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
Expand All @@ -274,10 +274,10 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand All @@ -288,8 +288,8 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -313,8 +313,8 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand All @@ -323,8 +323,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand Down
37 changes: 19 additions & 18 deletions rockset/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,24 +203,25 @@ func description() string {
}

type Values struct {
Name string
Alias string
Collection string
Description string
Workspace string
SQL string
Email string
FirstName string
LastName string
Roles []string
Role string
Bucket string
Tag string
Retention int
IngestTransformation string
CreateTimeout string
UseScanApi *bool
RCU *int
Name string
Alias string
Collection string
Description string
Workspace string
SQL string
Email string
FirstName string
LastName string
Roles []string
Role string
Bucket string
Tag string
Retention int
IngestTransformation string
CreateTimeout string
UseScanApi *bool
RCU *int
StorageCompressionType string
}

const S3IntegrationRoleArn = "arn:aws:iam::469279130686:role/terraform-provider-rockset-tests"
Expand Down
20 changes: 20 additions & 0 deletions rockset/resource_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ For more information see https://rockset.com/docs/ingest-transformation/`,
validation.IntBetween(3_600, 315_360_000),
),
},
"storage_compression_type": {
Description: "RocksDB storage compression type. Possible values: ZSTD, LZ4.",
Type: schema.TypeString,
ForceNew: true,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"ZSTD", "LZ4"}, false),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
// ignore unspecified storage_compression_type
return new == ""
},
},
"wait_for_collection": {
Description: "Wait until the collection is ready.",
Type: schema.TypeBool,
Expand Down Expand Up @@ -108,6 +119,11 @@ func parseBaseCollection(collection *openapi.Collection, d *schema.ResourceData)
return err
}

err = d.Set("storage_compression_type", collection.GetStorageCompressionType())
if err != nil {
return err
}

err = d.Set("ingest_transformation", collection.GetFieldMappingQuery().Sql)
if err != nil {
return err
Expand Down Expand Up @@ -136,6 +152,10 @@ func createBaseCollectionRequest(d *schema.ResourceData) *openapi.CreateCollecti
params.RetentionSecs = &retentionSeconds
}

if v, ok := d.GetOk("storage_compression_type"); ok {
params.SetStorageCompressionType(v.(string))
}

if v, ok := d.GetOk("ingest_transformation"); ok {
fmq := v.(string)
params.FieldMappingQuery = &openapi.FieldMappingQuery{Sql: &fmq}
Expand Down
Loading

0 comments on commit acfc941

Please sign in to comment.