8
8
9
9
10
10
class RedShiftDDLCompiler (PGDDLCompiler ):
11
+ ''' Handles Redshift specific create table syntax.
12
+
13
+ Users can specify the DISTSTYLE, DISTKEY, SORTKEY and ENCODE properties per
14
+ table and per column.
15
+
16
+ Table level properties can be set using the dialect specific syntax. For
17
+ example, to specify a distkey and style you apply the following ::
18
+
19
+ table = Table(metadata,
20
+ Column('id', Integer, primary_key=True),
21
+ Column('name', String),
22
+ redshift_diststyle="KEY",
23
+ redshift_distkey="id"
24
+ redshift_sortkey=["id", "name"]
25
+ )
26
+
27
+ A single sortkey can be applied without a wrapping list ::
28
+
29
+ table = Table(metadata,
30
+ Column('id', Integer, primary_key=True),
31
+ Column('name', String),
32
+ redshift_sortkey="id"
33
+ )
34
+
35
+ Column level special syntax can also be applied using the column info
36
+ dictionary. For example, we can specify the encode for a column ::
37
+
38
+ table = Table(metadata,
39
+ Column('id', Integer, primary_key=True),
40
+ Column('name', String, info={"encode":"lzo"})
41
+ )
42
+
43
+ We can also specify the distkey and sortkey options ::
44
+
45
+ table = Table(metadata,
46
+ Column('id', Integer, primary_key=True),
47
+ Column('name', String,
48
+ info={"distkey":True, "sortkey":True})
49
+ )
50
+
51
+ '''
11
52
12
53
def post_create_table (self , table ):
13
54
text = ""
@@ -34,9 +75,8 @@ def post_create_table(self, table):
34
75
return text
35
76
36
77
def get_column_specification (self , column , ** kwargs ):
37
- ''' Redshift doesn't support serial types, so they have been removed
38
- here.
39
- '''
78
+ # aron - Apr 21, 2014: Redshift doesn't support serial types. So I
79
+ # removed support for them here.
40
80
colspec = self .preparer .format_column (column )
41
81
colspec += " " + self .dialect .type_compiler .process (column .type )
42
82
0 commit comments