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

athena-driver #3014

Merged
merged 46 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2ee73b7
athena-driver
Sep 1, 2023
328f2ae
athena-driver
Sep 1, 2023
a047f82
athena-driver
Sep 4, 2023
dbba228
athena-driver
Sep 4, 2023
985f195
athena-driver review
Sep 5, 2023
3db7655
athena-driver review
Sep 5, 2023
5c66737
athena-driver review
Sep 5, 2023
605b791
athena-driver review
Sep 5, 2023
2008155
athena-driver review
Sep 5, 2023
00d3ec0
athena-driver review
Sep 5, 2023
dc52056
athena-driver review
Sep 6, 2023
d7e774b
athena-driver review
Sep 6, 2023
e68b2af
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 6, 2023
29b816e
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 6, 2023
e5f1794
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 6, 2023
549cf67
Run go mod tidy
begelundmuller Sep 7, 2023
e040606
athena-driver review
Sep 11, 2023
804f03e
athena-driver review
Sep 11, 2023
844877f
athena-driver review
Sep 12, 2023
f0bbee9
athena-driver review
Sep 12, 2023
8d4b69b
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 13, 2023
03d5c42
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 13, 2023
a5a5146
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 13, 2023
b7fc59d
athena-driver review
Sep 13, 2023
28606aa
athena-driver review
Sep 13, 2023
c6af926
athena-driver review
Sep 13, 2023
163788c
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 14, 2023
6d04765
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 14, 2023
45efd9a
Merge remote-tracking branch 'origin/main' into athena-connector
Sep 14, 2023
b594ed4
athena-driver review
Sep 21, 2023
7ab90bc
Merge remote-tracking branch 'origin/main' into athena-connector
esevastyanov Sep 22, 2023
bf2f044
Auto-determine AWS region
esevastyanov Sep 23, 2023
28f3e6e
Athena icon
esevastyanov Sep 23, 2023
18b423d
Removed the auto-resolving of AWS region
esevastyanov Sep 25, 2023
679e85d
Simplified a clean-up process
esevastyanov Sep 25, 2023
7e320ac
Merge remote-tracking branch 'origin/main' into athena-connector
esevastyanov Sep 25, 2023
3ab245d
Updated according to previously merged changes
esevastyanov Sep 25, 2023
804de57
Dash vs underscore
esevastyanov Sep 25, 2023
591a4ef
A new line after a query
esevastyanov Sep 25, 2023
bc7f95d
Non-nil NextContinuationToken
esevastyanov Sep 25, 2023
af69414
ctx cancellation instead of a hardcoded timer
esevastyanov Sep 25, 2023
0bd4d25
Format for FileIterator
esevastyanov Sep 25, 2023
a0d18da
deferred cleanupFn()
esevastyanov Sep 25, 2023
a1d0eb9
Aligned Athena query with a source config
esevastyanov Sep 25, 2023
6d72df9
Merge remote-tracking branch 'origin/main' into athena-connector
esevastyanov Sep 25, 2023
480aa95
Fixed a merge conflict
esevastyanov Sep 25, 2023
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
1 change: 1 addition & 0 deletions cli/cmd/runtime/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"golang.org/x/sync/errgroup"

// Load connectors and reconcilers for runtime
_ "github.com/rilldata/rill/runtime/drivers/athena"
_ "github.com/rilldata/rill/runtime/drivers/bigquery"
_ "github.com/rilldata/rill/runtime/drivers/druid"
_ "github.com/rilldata/rill/runtime/drivers/duckdb"
Expand Down
15 changes: 8 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/apache/arrow/go/v13 v13.0.0
github.com/apache/calcite-avatica-go/v5 v5.2.0
github.com/aws/aws-sdk-go v1.44.268
github.com/aws/aws-sdk-go-v2/service/athena v1.31.6
github.com/benbjohnson/clock v1.3.5
github.com/bmatcuk/doublestar/v4 v4.6.0
github.com/bradleyfalzon/ghinstallation/v2 v2.4.0
Expand Down Expand Up @@ -108,25 +109,25 @@ require (
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/apache/thrift v0.18.1 // indirect
github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.21.0
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.25 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.24 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.25
github.com/aws/aws-sdk-go-v2/credentials v1.13.24
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.25 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.28 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.2 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1
github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/aws/smithy-go v1.14.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down
14 changes: 10 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,9 @@ github.com/aws/aws-sdk-go v1.44.268 h1:WoK20tlAvsvQzTcE6TajoprbXmTbcud6MjhErL4P/
github.com/aws/aws-sdk-go v1.44.268/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4=
github.com/aws/aws-sdk-go-v2 v1.17.4/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY=
github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw=
github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc=
github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno=
github.com/aws/aws-sdk-go-v2/config v1.18.12/go.mod h1:J36fOhj1LQBr+O4hJCiT8FwVvieeoSGOtPuvhKlsNu8=
Expand All @@ -609,17 +610,21 @@ github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.51/go.mod h1:7Grl2gV+dx9SW
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67 h1:fI9/5BDEaAv/pv1VO1X1n3jfP9it+IGqWsCuuBQI8wM=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67/go.mod h1:zQClPRIwQZfJlZq6WZve+s4Tb4JW+3V6eS+4+KrYeP8=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28/go.mod h1:3lwChorpIM/BhImY/hy+Z6jekmN92cXGPI1QJasVPYY=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 h1:kG5eQilShqmJbv11XL1VpyDbaEJzWxd4zRiCG30GSn4=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33/go.mod h1:7i0PF1ME/2eUPFcjkVIwq+DOygHEoK92t5cDqNgYbIw=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22/go.mod h1:EqK7gVrIGAHyZItrD1D8B0ilgwMD1GiWAmbU4u/JHNk=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 h1:vFQlirhuM8lLlpI7imKOMsjdQLuN9CPi+k44F/OFVsk=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27/go.mod h1:UrHnn3QV/d0pBZ6QBAEQcqFLf8FAzLmoUfPVIueOvoM=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.29/go.mod h1:TwuqRBGzxjQJIwH16/fOZodwXt2Zxa9/cwJC5ke4j7s=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 h1:gGLG7yKaXG02/jBlg210R7VgQIotiQntNhsCFejawx8=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34/go.mod h1:Etz2dj6UHYuw+Xw830KfzCfWGMzqvUTCjUj5b76GVDc=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.19/go.mod h1:8W88sW3PjamQpKFUQvHWWKay6ARsNvZnzU7+a4apubw=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.25 h1:AzwRi5OKKwo4QNqPf7TjeO+tK8AyOK3GVSwmRPo7/Cs=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.25/go.mod h1:SUbB4wcbSEyCvqBxv/O/IBf93RbEze7U7OnoTlpPB+g=
github.com/aws/aws-sdk-go-v2/service/athena v1.31.6 h1:EFaTu1rBt+KQglDeYRpP1PHot/6xlYzvouxm2aRmrG8=
github.com/aws/aws-sdk-go-v2/service/athena v1.31.6/go.mod h1:DHafyhR8x70ANJZ2RkJx8oeJsfEBqaGwZ591vlihVFQ=
github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8=
Expand Down Expand Up @@ -650,8 +655,9 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.18.3/go.mod h1:b+psTJn33Q4qGoDaM7ZiO
github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 h1:2DQLAKDteoEDI8zpCzqBMaZlJuoE9iTYD0gFmXVax9E=
github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8=
github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8=
github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ=
github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down
2 changes: 1 addition & 1 deletion runtime/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (r *Runtime) connectorConfig(ctx context.Context, instanceID, name string)
// For backwards compatibility, certain root-level variables apply to certain implicit connectors.
// NOTE: This switches on connector.Name, not connector.Type, because this only applies to implicit connectors.
switch connector.Name {
case "s3":
case "s3", "athena":
setIfNil(cfg, "aws_access_key_id", vars["aws_access_key_id"])
setIfNil(cfg, "aws_secret_access_key", vars["aws_secret_access_key"])
setIfNil(cfg, "aws_session_token", vars["aws_session_token"])
Expand Down
177 changes: 177 additions & 0 deletions runtime/drivers/athena/athena.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
package athena

import (
"context"
"fmt"

"github.com/mitchellh/mapstructure"
"github.com/rilldata/rill/runtime/drivers"
"github.com/rilldata/rill/runtime/pkg/activity"
"go.uber.org/zap"
)

func init() {
drivers.Register("athena", driver{})
drivers.RegisterAsConnector("athena", driver{})
}

var spec = drivers.Spec{
DisplayName: "Amazon Athena",
Description: "Connect to Amazon Athena database.",
ServiceAccountDocs: "",
SourceProperties: []drivers.PropertySchema{
{
Key: "sql",
Type: drivers.StringPropertyType,
Required: true,
DisplayName: "SQL",
Description: "Query to extract data from Athena.",
Placeholder: "select * from catalog.table;",
},
{
Key: "output_location",
DisplayName: "S3 output location",
Description: "Output location for query results in S3.",
Placeholder: "s3://bucket-name/path/",
Type: drivers.StringPropertyType,
Required: false,
},
{
Key: "workgroup",
DisplayName: "AWS Athena workgroup",
Description: "AWS Athena workgroup to use for queries.",
Placeholder: "primary",
Type: drivers.StringPropertyType,
Required: false,
},
{
Key: "region",
DisplayName: "AWS region",
Description: "AWS region to connect to Athena and the output location.",
Placeholder: "us-east-1",
Type: drivers.StringPropertyType,
Required: false,
},
},
ConfigProperties: []drivers.PropertySchema{
{
Key: "aws_access_key_id",
Secret: true,
},
{
Key: "aws_secret_access_key",
Secret: true,
},
},
}

type driver struct{}

func (d driver) Open(config map[string]any, shared bool, _ activity.Client, logger *zap.Logger) (drivers.Handle, error) {
if shared {
return nil, fmt.Errorf("athena driver can't be shared")
}
conf := &configProperties{}
err := mapstructure.Decode(config, conf)
if err != nil {
return nil, err
}

conn := &Connection{
config: conf,
logger: logger,
}
return conn, nil
}

func (d driver) Drop(config map[string]any, logger *zap.Logger) error {
return drivers.ErrDropNotSupported
}

func (d driver) Spec() drivers.Spec {
return spec
}

func (d driver) HasAnonymousSourceAccess(ctx context.Context, src map[string]any, logger *zap.Logger) (bool, error) {
return false, nil
}

type Connection struct {
config *configProperties
logger *zap.Logger
}

var _ drivers.Handle = &Connection{}

// Driver implements drivers.Connection.
func (c *Connection) Driver() string {
return "athena"
}

// Config implements drivers.Connection.
func (c *Connection) Config() map[string]any {
m := make(map[string]any, 0)
_ = mapstructure.Decode(c.config, m)
return m
}

// Close implements drivers.Connection.
func (c *Connection) Close() error {
return nil
}

// Registry implements drivers.Connection.
func (c *Connection) AsRegistry() (drivers.RegistryStore, bool) {
return nil, false
}

// Catalog implements drivers.Connection.
func (c *Connection) AsCatalogStore(instanceID string) (drivers.CatalogStore, bool) {
return nil, false
}

// Repo implements drivers.Connection.
func (c *Connection) AsRepoStore(instanceID string) (drivers.RepoStore, bool) {
return nil, false
}

// OLAP implements drivers.Connection.
func (c *Connection) AsOLAP(instanceID string) (drivers.OLAPStore, bool) {
return nil, false
}

// Migrate implements drivers.Connection.
func (c *Connection) Migrate(ctx context.Context) (err error) {
return nil
}

// MigrationStatus implements drivers.Connection.
func (c *Connection) MigrationStatus(ctx context.Context) (current, desired int, err error) {
return 0, 0, nil
}

// AsObjectStore implements drivers.Connection.
func (c *Connection) AsObjectStore() (drivers.ObjectStore, bool) {
return nil, false
}

// AsTransporter implements drivers.Connection.
func (c *Connection) AsTransporter(from, to drivers.Handle) (drivers.Transporter, bool) {
return nil, false
}

func (c *Connection) AsFileStore() (drivers.FileStore, bool) {
return nil, false
}

// AsSQLStore implements drivers.Connection.
func (c *Connection) AsSQLStore() (drivers.SQLStore, bool) {
return c, true
}

type configProperties struct {
AccessKeyID string `mapstructure:"aws_access_key_id"`
SecretAccessKey string `mapstructure:"aws_secret_access_key"`
SessionToken string `mapstructure:"aws_access_token"`
AllowHostAccess bool `mapstructure:"allow_host_access"`
}
Loading