-
Notifications
You must be signed in to change notification settings - Fork 351
/
metastore.go
133 lines (120 loc) · 3.31 KB
/
metastore.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package metastore
import (
"strings"
"time"
"github.com/aws/aws-sdk-go/service/glue"
)
func (m *Table) Update(db, table, serde string, transformLocation func(location string) (string, error)) error {
if m.Sd == nil {
m.Sd = &StorageDescriptor{}
}
if m.Sd.SerdeInfo == nil {
m.Sd.SerdeInfo = &SerDeInfo{}
}
m.DBName = db
m.TableName = table
m.Sd.SerdeInfo.Name = serde
var err error
if m.Sd.Location != "" {
m.Sd.Location, err = transformLocation(m.Sd.Location)
}
return err
}
func (m *Partition) Update(db, table, serde string, transformLocation func(location string) (string, error)) error {
if m.Sd == nil {
m.Sd = &StorageDescriptor{}
}
if m.Sd.SerdeInfo == nil {
m.Sd.SerdeInfo = &SerDeInfo{}
}
m.DBName = db
m.TableName = table
m.Sd.SerdeInfo.Name = serde
var err error
if m.Sd.Location != "" {
m.Sd.Location, err = transformLocation(m.Sd.Location)
}
return err
}
type Database struct {
Name string
Description string
LocationURI string
Parameters map[string]string
HivePrivileges interface{}
OwnerName *string
HiveOwnerType interface{}
AWSTargetDatabase *glue.DatabaseIdentifier
}
type Table struct {
TableName string
DBName string
Owner string
CreateTime int64
LastAccessTime int64
Retention int
Sd *StorageDescriptor
PartitionKeys []*FieldSchema
Parameters map[string]string
ViewOriginalText string
ViewExpandedText string
TableType string
Temporary bool
RewriteEnabled *bool
AWSCreatedBy *string
AWSDescription *string
AWSIsRegisteredWithLakeFormation *bool
AWSLastAnalyzedTime *time.Time
AWSTargetTable interface{}
AWSUpdateTime *time.Time
Privileges interface{}
}
type Partition struct {
Values []string
DBName string
TableName string
CreateTime int
LastAccessTime int
Sd *StorageDescriptor
Parameters map[string]string
AWSLastAnalyzedTime *time.Time
Privileges interface{}
}
type StorageDescriptor struct {
Cols []*FieldSchema
Location string
InputFormat string
OutputFormat string
Compressed bool
NumBuckets int
SerdeInfo *SerDeInfo
BucketCols []string
SortCols []*Order
Parameters map[string]string
SkewedInfo *SkewedInfo
StoredAsSubDirectories *bool
AWSSchemaReference interface{}
}
type SerDeInfo struct {
Name string
SerializationLib string
Parameters map[string]string
}
type FieldSchema struct {
Name string
Type string
Comment string
}
type Order struct {
Col string
Order int
}
type SkewedInfo struct {
SkewedColNames []string
SkewedColValues [][]string
AWSSkewedColValues []string //
SkewedColValueLocationMaps map[string]string
}
func (m Partition) Name() string {
return strings.Join(m.Values, "-")
}