-
Notifications
You must be signed in to change notification settings - Fork 26
/
tableid.go
44 lines (34 loc) · 929 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
38
39
40
41
42
43
44
package snowflake
import (
"fmt"
"github.com/artie-labs/transfer/lib/destination/types"
"github.com/artie-labs/transfer/lib/sql"
)
var dialect = sql.SnowflakeDialect{UppercaseEscNames: true}
type TableIdentifier struct {
database string
schema string
table string
}
func NewTableIdentifier(database, schema, table string) TableIdentifier {
return TableIdentifier{
database: database,
schema: schema,
table: table,
}
}
func (ti TableIdentifier) Database() string {
return ti.database
}
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.database, ti.schema, table)
}
func (ti TableIdentifier) FullyQualifiedName() string {
return fmt.Sprintf("%s.%s.%s", ti.database, ti.schema, dialect.QuoteIdentifier(ti.table))
}