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

add support for trino data sources #48

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions pkg/database-types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const S3 = "s3"
const Scheme = "scheme"
const SecretAccessID = "secret_access_id"
const SecurityConfig = "securityConfig"
const Trino = "Trino"
const Type = "type"
const Username = "username"
const Value = "value"
74 changes: 74 additions & 0 deletions pkg/database-types/trino.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright 2022 IBM Corp.
// SPDX-License-Identifier: Apache-2.0

package databasetypes

import (
"fmt"
"reflect"

"github.com/rs/zerolog"

models "fybrik.io/openmetadata-connector/datacatalog-go-models"
"fybrik.io/openmetadata-connector/pkg/utils"
)

type trino struct {
dataBase
}

func NewTrino(logger *zerolog.Logger) *trino {
return &trino{dataBase: dataBase{name: Trino, logger: logger}}
}

func (t *trino) TranslateFybrikConfigToOpenMetadataConfig(config map[string]interface{},
connectionType string, credentials *string) map[string]interface{} {
return config
}

func (t *trino) TranslateOpenMetadataConfigToFybrikConfig(tableName string,
config map[string]interface{}) (map[string]interface{}, string, error) {
return config, Trino, nil
}

func (t *trino) TableFQN(serviceName string, createAssetRequest *models.CreateAssetRequest) (string, error) {
connectionProperties, ok := utils.InterfaceToMap(createAssetRequest.Details.GetConnection().AdditionalProperties["trino"], t.logger)
if !ok {
return EmptyString, fmt.Errorf(FailedToConvert, AdditionalProperties)
}
assetName := *createAssetRequest.DestinationAssetID
databaseSchema, found := connectionProperties[DatabaseSchema]
if found {
return fmt.Sprintf("%s.%s.%s.%s", serviceName, Default, databaseSchema.(string), assetName), nil
}
return fmt.Sprintf("%s.%s.%s", serviceName, Default, assetName), nil
}

func (t *trino) EquivalentServiceConfigurations(requestConfig, serviceConfig map[string]interface{}) bool {
for property, value := range requestConfig {
if !reflect.DeepEqual(serviceConfig[property], value) {
return false
}
}
return true
}

func (t *trino) DatabaseName(createAssetRequest *models.CreateAssetRequest) string {
return Default
}

func (t *trino) DatabaseFQN(serviceName string, createAssetRequest *models.CreateAssetRequest) string {
return EmptyString
}

func (t *trino) DatabaseSchemaName(createAssetRequest *models.CreateAssetRequest) string {
return EmptyString
}

func (t *trino) DatabaseSchemaFQN(serviceName string, createAssetRequest *models.CreateAssetRequest) string {
return EmptyString
}

func (t *trino) TableName(createAssetRequest *models.CreateAssetRequest) (string, error) {
return EmptyString, nil
}
2 changes: 2 additions & 0 deletions pkg/openmetadata-connector-core/connector_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,14 @@ func NewOpenMetadataAPIService(conf map[string]interface{}, customization map[st
MysqlLowercase: dbtypes.NewMysql(logger),
S3: dbtypes.NewS3(vaultConf, logger),
Generic: dbtypes.NewGeneric(logger),
TrinoLowercase: dbtypes.NewTrino(logger),
}

serviceTypeToConnectionType := map[string]string{
dbtypes.Datalake: S3,
dbtypes.Mysql: MysqlLowercase,
dbtypes.CustomDatabase: Generic,
dbtypes.Trino: TrinoLowercase,
}

s := &OpenMetadataAPIService{Endpoint: conf["openmetadata_endpoint"].(string),
Expand Down
1 change: 1 addition & 0 deletions pkg/openmetadata-connector-core/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const TableProperties = "table-properties"
const TagCategories = "tag-categories"
const Tags = "tags"
const TagsPath = "/tags"
const TrinoLowercase = "trino"
const True = "true"
const Type = "type"
const TypeListLengthLimit = 100
Expand Down