Skip to content

Commit

Permalink
feat(stripe)!: Migrate to Arrow native SDK (#10979)
Browse files Browse the repository at this point in the history
Closes #10768

BEGIN_COMMIT_OVERRIDE
feat: Update to use [Apache Arrow](https://arrow.apache.org/) type system (#10979)

BREAKING-CHANGE: This release introduces an internal change to our type system to use [Apache Arrow](https://arrow.apache.org/). This should not have any visible breaking changes, however due to the size of the change we are introducing it under a major version bump to communicate that it might have some bugs that we weren't able to catch during our internal tests. If you encounter an issue during the upgrade, please submit a [bug report](https://github.com/cloudquery/cloudquery/issues/new/choose). You will also need to update destinations depending on which one you use:
- Azure Blob Storage >= v3.2.0
- BigQuery >= v3.0.0
- ClickHouse >= v3.1.1
- DuckDB >= v1.1.6
- Elasticsearch >= v2.0.0
- File >= v3.2.0
- Firehose >= v2.0.2
- GCS >= v3.2.0
- Gremlin >= v2.1.10
- Kafka >= v3.0.1
- Meilisearch >= v2.0.1
- Microsoft SQL Server >= v4.2.0
- MongoDB >= v2.0.1
- MySQL >= v2.0.2
- Neo4j >= v3.0.0
- PostgreSQL >= v4.2.0
- S3 >= v4.4.0
- Snowflake >= v2.1.1
- SQLite >= v2.2.0

END_COMMIT_OVERRIDE
  • Loading branch information
disq committed May 26, 2023
1 parent 60ef066 commit 5216f87
Show file tree
Hide file tree
Showing 143 changed files with 2,103 additions and 2,236 deletions.
6 changes: 3 additions & 3 deletions plugins/source/stripe/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"time"

"github.com/cloudquery/plugin-pb-go/specs"
"github.com/cloudquery/plugin-sdk/v2/backend"
"github.com/cloudquery/plugin-sdk/v2/plugins/source"
"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v3/backend"
"github.com/cloudquery/plugin-sdk/v3/plugins/source"
"github.com/cloudquery/plugin-sdk/v3/schema"
"github.com/rs/zerolog"
"github.com/stripe/stripe-go/v74"
"github.com/stripe/stripe-go/v74/client"
Expand Down
2 changes: 1 addition & 1 deletion plugins/source/stripe/client/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"reflect"

"github.com/cloudquery/plugin-sdk/v2/transformers"
"github.com/cloudquery/plugin-sdk/v3/transformers"
)

func CreateIgnoreInTestsTransformer(fieldNames ...string) transformers.IgnoreInTestsTransformer {
Expand Down
6 changes: 3 additions & 3 deletions plugins/source/stripe/client/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"time"

"github.com/cloudquery/plugin-pb-go/specs"
"github.com/cloudquery/plugin-sdk/v2/backend"
"github.com/cloudquery/plugin-sdk/v2/plugins/source"
"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v3/backend"
"github.com/cloudquery/plugin-sdk/v3/plugins/source"
"github.com/cloudquery/plugin-sdk/v3/schema"
"github.com/rs/zerolog"
"github.com/stripe/stripe-go/v74"
sclient "github.com/stripe/stripe-go/v74/client"
Expand Down
11 changes: 6 additions & 5 deletions plugins/source/stripe/client/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package client
import (
"reflect"

"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v2/transformers"
"github.com/apache/arrow/go/v13/arrow"
"github.com/cloudquery/plugin-sdk/v3/schema"
"github.com/cloudquery/plugin-sdk/v3/transformers"
)

var options = []transformers.StructTransformerOption{
Expand All @@ -14,10 +15,10 @@ var options = []transformers.StructTransformerOption{
func TransformWithStruct(t any, opts ...transformers.StructTransformerOption) schema.Transform {
return transformers.TransformWithStruct(t, append(options, opts...)...)
}
func typeTransformer(field reflect.StructField) (schema.ValueType, error) {
func typeTransformer(field reflect.StructField) (arrow.DataType, error) {
if field.Name == "Created" && field.Type == reflect.TypeOf(int64(0)) {
return schema.TypeTimestamp, nil
return arrow.FixedWidthTypes.Timestamp_us, nil
}

return schema.TypeInvalid, nil
return nil, nil
}
4 changes: 2 additions & 2 deletions plugins/source/stripe/codegen/fixtures/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"strings"

"github.com/cloudquery/cloudquery/plugins/source/stripe/codegen/recipes"
"github.com/cloudquery/plugin-sdk/v2/caser"
"github.com/cloudquery/plugin-sdk/v2/faker"
"github.com/cloudquery/plugin-sdk/v3/caser"
"github.com/cloudquery/plugin-sdk/v3/faker"
"github.com/stripe/stripe-go/v74"
)

Expand Down
2 changes: 1 addition & 1 deletion plugins/source/stripe/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"text/template"

"github.com/cloudquery/cloudquery/plugins/source/stripe/codegen/recipes"
"github.com/cloudquery/plugin-sdk/v2/caser"
"github.com/cloudquery/plugin-sdk/v3/caser"
"github.com/gertd/go-pluralize"
)

Expand Down
2 changes: 1 addition & 1 deletion plugins/source/stripe/codegen/recipes/recipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"strings"

"github.com/cloudquery/plugin-sdk/v2/caser"
"github.com/cloudquery/plugin-sdk/v3/caser"
"github.com/gertd/go-pluralize"
)

Expand Down
14 changes: 7 additions & 7 deletions plugins/source/stripe/codegen/templates/get.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package {{.Service}}
import (
"context"

"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v2/transformers"
{{if .HasIDPK}}
"github.com/apache/arrow/go/v13/arrow"
{{end -}}
"github.com/cloudquery/plugin-sdk/v3/schema"
"github.com/cloudquery/plugin-sdk/v3/transformers"
"github.com/cloudquery/cloudquery/plugins/source/stripe/client"
"github.com/stripe/stripe-go/v74"
)
Expand All @@ -24,12 +27,9 @@ func {{.TableName | ToPascal}}() *schema.Table {
Columns: []schema.Column{
{
Name: "id",
Type: schema.TypeString,
Type: arrow.BinaryTypes.String,
Resolver: schema.PathResolver("ID"),
CreationOptions: schema.ColumnCreationOptions{
PrimaryKey: true,
},
},
PrimaryKey: true,
},
{{end}}
{{if or .Children .ExtraChildren}}
Expand Down
27 changes: 13 additions & 14 deletions plugins/source/stripe/codegen/templates/list.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import (
"strconv"
{{end}}

"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v2/transformers"
{{if or .HasIDPK .StateParamName}}
"github.com/apache/arrow/go/v13/arrow"
{{end -}}
"github.com/cloudquery/plugin-sdk/v3/schema"
"github.com/cloudquery/plugin-sdk/v3/transformers"
"github.com/cloudquery/cloudquery/plugins/source/stripe/client"
"github.com/stripe/stripe-go/v74"
)
Expand All @@ -27,21 +30,17 @@ func {{.TableName | ToPascal}}() *schema.Table {
{{if .HasIDPK}}
Columns: []schema.Column{
{
Name: "id",
Type: schema.TypeString,
Resolver: schema.PathResolver("ID"),
CreationOptions: schema.ColumnCreationOptions{
PrimaryKey: true,
},
Name: "id",
Type: arrow.BinaryTypes.String,
Resolver: schema.PathResolver("ID"),
PrimaryKey: true,
},
{{if .StateParamName -}}
{
Name: "{{.StateParamName | ToSnake}}",
Type: schema.TypeTimestamp,
Resolver: schema.PathResolver("{{.StateParamName}}"),
CreationOptions: schema.ColumnCreationOptions{
IncrementalKey: true,
},
Name: "{{.StateParamName | ToSnake}}",
Type: arrow.FixedWidthTypes.Timestamp_us,
Resolver: schema.PathResolver("{{.StateParamName}}"),
IncrementalKey: true,
},
{{end -}}
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/source/stripe/codegen/templates/tables.go.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package plugin

import (
"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v3/schema"
{{- range $resource := . }}
"github.com/cloudquery/cloudquery/plugins/source/stripe/resources/services/{{ $resource.Service }}"
{{- end }}
Expand Down
9 changes: 5 additions & 4 deletions plugins/source/stripe/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ module github.com/cloudquery/cloudquery/plugins/source/stripe
go 1.19

require (
github.com/apache/arrow/go/v13 v13.0.0-20230509040948-de6c3cd2b604
github.com/cloudquery/plugin-pb-go v1.0.8
github.com/cloudquery/plugin-sdk/v2 v2.7.0
github.com/cloudquery/plugin-sdk/v3 v3.6.4
github.com/gertd/go-pluralize v0.2.1
github.com/rs/zerolog v1.29.0
github.com/stripe/stripe-go/v74 v74.16.0
github.com/stripe/stripe-mock v0.148.0
golang.org/x/time v0.3.0
)

// TODO: remove once all updates are merged
replace github.com/apache/arrow/go/v13 => github.com/cloudquery/arrow/go/v13 v13.0.0-20230509053643-898a79b1d3c8
replace github.com/apache/arrow/go/v13 => github.com/cloudquery/arrow/go/v13 v13.0.0-20230525142029-2d32efeedad8

require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/apache/arrow/go/v13 v13.0.0-20230509040948-de6c3cd2b604 // indirect
github.com/apache/thrift v0.16.0 // indirect
github.com/cloudquery/plugin-sdk/v2 v2.7.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/getsentry/sentry-go v0.20.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
Expand All @@ -44,6 +44,7 @@ require (
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
Expand Down
7 changes: 5 additions & 2 deletions plugins/source/stripe/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudquery/arrow/go/v13 v13.0.0-20230509053643-898a79b1d3c8 h1:CmgLSEGQNLHpUQ5cU4L4aF7cuJZRnc1toIIWqC1gmPg=
github.com/cloudquery/arrow/go/v13 v13.0.0-20230509053643-898a79b1d3c8/go.mod h1:/XatdE3kDIBqZKhZ7OBUHwP2jaASDFZHqF4puOWM8po=
github.com/cloudquery/arrow/go/v13 v13.0.0-20230525142029-2d32efeedad8 h1:/mgK+To5HNUzuZDWdVygbfn8oaPG5c7I/8qCxwwpWO8=
github.com/cloudquery/arrow/go/v13 v13.0.0-20230525142029-2d32efeedad8/go.mod h1:/XatdE3kDIBqZKhZ7OBUHwP2jaASDFZHqF4puOWM8po=
github.com/cloudquery/plugin-pb-go v1.0.8 h1:wn3GXhcNItcP+6wUUZuzUFbvdL59liKBO37/izMi+FQ=
github.com/cloudquery/plugin-pb-go v1.0.8/go.mod h1:vAGA27psem7ZZNAY4a3S9TKuA/JDQWstjKcHPJX91Mc=
github.com/cloudquery/plugin-sdk/v2 v2.7.0 h1:hRXsdEiaOxJtsn/wZMFQC9/jPfU1MeMK3KF+gPGqm7U=
github.com/cloudquery/plugin-sdk/v2 v2.7.0/go.mod h1:pAX6ojIW99b/Vg4CkhnsGkRIzNaVEceYMR+Bdit73ug=
github.com/cloudquery/plugin-sdk/v3 v3.6.4 h1:P4OkS5tJYkv3OqeL60DAVqXXbFQUyPKJ5YDtAgjl9b4=
github.com/cloudquery/plugin-sdk/v3 v3.6.4/go.mod h1:3JrZXEULmGXpkOukVaRIzaA63d7TJr9Ukp6hemTjbtc=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
Expand Down Expand Up @@ -194,6 +196,7 @@ github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 h1:+n/aFZefKZp7spd8D
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0=
github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pkg/errors v0.8.1-0.20170505043639-c605e284fe17/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
2 changes: 1 addition & 1 deletion plugins/source/stripe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"github.com/cloudquery/cloudquery/plugins/source/stripe/resources/plugin"
"github.com/cloudquery/plugin-sdk/v2/serve"
"github.com/cloudquery/plugin-sdk/v3/serve"
)

const sentryDSN = "https://4606a1601b52488889313375ba91df89@o1396617.ingest.sentry.io/4504441433751552"
Expand Down
2 changes: 1 addition & 1 deletion plugins/source/stripe/resources/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package plugin

import (
"github.com/cloudquery/cloudquery/plugins/source/stripe/client"
"github.com/cloudquery/plugin-sdk/v2/plugins/source"
"github.com/cloudquery/plugin-sdk/v3/plugins/source"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion plugins/source/stripe/resources/plugin/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/cloudquery/cloudquery/plugins/source/stripe/resources/services/transfers"
"github.com/cloudquery/cloudquery/plugins/source/stripe/resources/services/treasury"
"github.com/cloudquery/cloudquery/plugins/source/stripe/resources/services/webhook_endpoints"
"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v3/schema"
)

func tables() []*schema.Table {
Expand Down
25 changes: 11 additions & 14 deletions plugins/source/stripe/resources/services/accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"fmt"
"strconv"

"github.com/apache/arrow/go/v13/arrow"
"github.com/cloudquery/cloudquery/plugins/source/stripe/client"
"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v2/transformers"
"github.com/cloudquery/plugin-sdk/v3/schema"
"github.com/cloudquery/plugin-sdk/v3/transformers"
"github.com/stripe/stripe-go/v74"
)

Expand All @@ -20,20 +21,16 @@ func Accounts() *schema.Table {

Columns: []schema.Column{
{
Name: "id",
Type: schema.TypeString,
Resolver: schema.PathResolver("ID"),
CreationOptions: schema.ColumnCreationOptions{
PrimaryKey: true,
},
Name: "id",
Type: arrow.BinaryTypes.String,
Resolver: schema.PathResolver("ID"),
PrimaryKey: true,
},
{
Name: "created",
Type: schema.TypeTimestamp,
Resolver: schema.PathResolver("Created"),
CreationOptions: schema.ColumnCreationOptions{
IncrementalKey: true,
},
Name: "created",
Type: arrow.FixedWidthTypes.Timestamp_us,
Resolver: schema.PathResolver("Created"),
IncrementalKey: true,
},
},
IsIncremental: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package accounts
import (
"context"

"github.com/apache/arrow/go/v13/arrow"
"github.com/cloudquery/cloudquery/plugins/source/stripe/client"
"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v2/transformers"
"github.com/cloudquery/plugin-sdk/v3/schema"
"github.com/cloudquery/plugin-sdk/v3/transformers"
"github.com/stripe/stripe-go/v74"
)

Expand All @@ -18,12 +19,10 @@ func Capabilities() *schema.Table {

Columns: []schema.Column{
{
Name: "id",
Type: schema.TypeString,
Resolver: schema.PathResolver("ID"),
CreationOptions: schema.ColumnCreationOptions{
PrimaryKey: true,
},
Name: "id",
Type: arrow.BinaryTypes.String,
Resolver: schema.PathResolver("ID"),
PrimaryKey: true,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package apple_pay_domains
import (
"context"

"github.com/apache/arrow/go/v13/arrow"
"github.com/cloudquery/cloudquery/plugins/source/stripe/client"
"github.com/cloudquery/plugin-sdk/v2/schema"
"github.com/cloudquery/plugin-sdk/v2/transformers"
"github.com/cloudquery/plugin-sdk/v3/schema"
"github.com/cloudquery/plugin-sdk/v3/transformers"
"github.com/stripe/stripe-go/v74"
)

Expand All @@ -18,12 +19,10 @@ func ApplePayDomains() *schema.Table {

Columns: []schema.Column{
{
Name: "id",
Type: schema.TypeString,
Resolver: schema.PathResolver("ID"),
CreationOptions: schema.ColumnCreationOptions{
PrimaryKey: true,
},
Name: "id",
Type: arrow.BinaryTypes.String,
Resolver: schema.PathResolver("ID"),
PrimaryKey: true,
},
},
}
Expand Down

0 comments on commit 5216f87

Please sign in to comment.