-
Notifications
You must be signed in to change notification settings - Fork 26
/
tableid.go
37 lines (28 loc) · 900 Bytes
/
tableid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package redshift
import (
"fmt"
"github.com/artie-labs/transfer/lib/destination/types"
"github.com/artie-labs/transfer/lib/sql"
)
var dialect = sql.RedshiftDialect{}
type TableIdentifier struct {
schema string
table string
}
func NewTableIdentifier(schema, table string) TableIdentifier {
return TableIdentifier{schema: schema, table: table}
}
func (ti TableIdentifier) Schema() string {
return ti.schema
}
func (ti TableIdentifier) Table() string {
return ti.table
}
func (ti TableIdentifier) WithTable(table string) types.TableIdentifier {
return NewTableIdentifier(ti.schema, table)
}
func (ti TableIdentifier) FullyQualifiedName() string {
// Redshift is Postgres compatible, so when establishing a connection, we'll specify a database.
// Thus, we only need to specify schema and table name here.
return fmt.Sprintf("%s.%s", ti.schema, dialect.QuoteIdentifier(ti.table))
}