Skip to content

Commit f2ed08f

Browse files
[td] 0.6.5 (mage-ai#1247)
* [td] 0.6.5 * update constants
1 parent 233c077 commit f2ed08f

File tree

21 files changed

+1431
-25
lines changed

21 files changed

+1431
-25
lines changed

Diff for: docs/data_integrations/README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ Read more about Sources:
5656

5757
### Available sources
5858

59-
- [Amplitude](../../mage_integrations/sources/amplitude/README.md)
60-
- [MySQL](../../mage_integrations/sources/mysql/README.md)
61-
- [Salesforce](../../mage_integrations/sources/salesforce/README.md)
62-
- [Stripe](../../mage_integrations/sources/stripe/README.md)
59+
- [Amplitude](../../mage_integrations/mage_integrations/sources/amplitude/README.md)
60+
- [MySQL](../../mage_integrations/mage_integrations/sources/mysql/README.md)
61+
- [Redshift (Amazon Web Services)](../../mage_integrations/mage_integrations/sources/redshift/README.md)
62+
- [Salesforce](../../mage_integrations/mage_integrations/sources/salesforce/README.md)
63+
- [Stripe](../../mage_integrations/mage_integrations/sources/stripe/README.md)
6364
- *Airtable (coming soon)*
6465
- *Chargebee (coming soon)*
6566
- *Google Analytics (coming soon)*
@@ -94,9 +95,9 @@ Read more about destinations:
9495

9596
### Available destinations
9697

97-
- [MySQL](../../mage_integrations/destinations/mysql/README.md)
98-
- [PostgreSQL](../../mage_integrations/destinations/postgresql/README.md)
99-
- [Snowflake](../../mage_integrations/destinations/snowflake/README.md)
98+
- [MySQL](../../mage_integrations/mage_integrations/destinations/mysql/README.md)
99+
- [PostgreSQL](../../mage_integrations/mage_integrations/destinations/postgresql/README.md)
100+
- [Snowflake](../../mage_integrations/mage_integrations/destinations/snowflake/README.md)
100101
- *Amazon Web Services (AWS) Redshift (coming soon)*
101102
- *Amazon Web Services (AWS) S3 (coming soon)*
102103
- *Azure Blob Storage (coming soon)*

Diff for: mage_ai/data_integrations/sources/constants.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SOURCES = [
22
dict(name='Amplitude'),
33
dict(name='MySQL'),
4+
dict(name='Redshift'),
45
dict(name='Salesforce'),
56
dict(name='Stripe'),
67
]

Diff for: mage_ai/server/constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
DATAFRAME_OUTPUT_SAMPLE_COUNT = 10
99

10-
VERSION = '0.6.4'
10+
VERSION = '0.6.5'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from mage_integrations.connections.sql.base import Connection
2+
from redshift_connector import connect
3+
4+
5+
class Redshift(Connection):
6+
def __init__(
7+
self,
8+
access_key_id: str = None,
9+
cluster_identifier: str = None,
10+
database: str = None,
11+
db_user: str = None,
12+
host: str = None,
13+
password: str = None,
14+
port: int = None,
15+
region: str = None,
16+
secret_access_key: str = None,
17+
user: str = None,
18+
**kwargs,
19+
):
20+
super().__init__(**kwargs)
21+
self.access_key_id = access_key_id
22+
self.cluster_identifier = cluster_identifier
23+
self.database = database
24+
self.db_user = db_user
25+
self.host = host
26+
self.password = password
27+
self.port = port or 5439
28+
self.region = region
29+
self.secret_access_key = secret_access_key
30+
self.user = user
31+
32+
def build_connection(self):
33+
# https://github.com/aws/amazon-redshift-python-driver#connection-parameters
34+
return connect(
35+
access_key_id=self.access_key_id,
36+
cluster_identifier=self.cluster_identifier,
37+
database=self.database,
38+
db_user=self.db_user,
39+
host=self.host,
40+
password=self.password,
41+
port=self.port,
42+
region=self.region,
43+
secret_access_key=self.secret_access_key,
44+
user=self.user,
45+
)

Diff for: mage_integrations/mage_integrations/destinations/mysql/utils.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from mage_integrations.destinations.mysql.constants import RESERVED_WORDS
2+
from mage_integrations.destinations.sql.constants import SQL_RESERVED_WORDS
23
from mage_integrations.destinations.utils import clean_column_name as clean_column_name_orig
34
from mage_integrations.sources.constants import (
45
COLUMN_FORMAT_DATETIME,
@@ -14,7 +15,7 @@
1415

1516
def clean_column_name(col):
1617
col_new = clean_column_name_orig(col)
17-
if col_new.upper() in RESERVED_WORDS:
18+
if col_new.upper() in (RESERVED_WORDS + SQL_RESERVED_WORDS):
1819
col_new = f'_{col_new}'
1920
return col_new
2021

@@ -48,7 +49,8 @@ def build_create_table_command(
4849
if unique_constraints:
4950
cols = [clean_column_name(col) for col in unique_constraints]
5051
index_name = '_'.join(cols)
51-
columns_and_types.append(f"CONSTRAINT unique_{index_name} Unique({', '.join(cols)})")
52+
index_name = f'unique_{index_name}'[:64]
53+
columns_and_types.append(f"CONSTRAINT {index_name} Unique({', '.join(cols)})")
5254

5355
if key_properties and len(key_properties) >= 1:
5456
col = clean_column_name(key_properties[0])

Diff for: mage_integrations/mage_integrations/destinations/redshift/README.md

Whitespace-only changes.

Diff for: mage_integrations/mage_integrations/destinations/redshift/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
REDSHIFT_RESERVED_WORDS = [
2+
'AES128',
3+
'AES256',
4+
'ALL',
5+
'ALLOWOVERWRITE',
6+
'ANALYSE',
7+
'ANALYZE',
8+
'AND',
9+
'ANY',
10+
'ARRAY',
11+
'AS',
12+
'ASC',
13+
'AUTHORIZATION',
14+
'AZ64',
15+
'BACKUP',
16+
'BETWEEN',
17+
'BINARY',
18+
'BLANKSASNULL',
19+
'BOTH',
20+
'BYTEDICT',
21+
'BZIP2',
22+
'CASE',
23+
'CAST',
24+
'CHECK',
25+
'COLLATE',
26+
'COLUMN',
27+
'CONSTRAINT',
28+
'CREATE',
29+
'CREDENTIALS',
30+
'CROSS',
31+
'CURRENT_DATE',
32+
'CURRENT_TIME',
33+
'CURRENT_TIMESTAMP',
34+
'CURRENT_USER',
35+
'CURRENT_USER_ID',
36+
'DEFAULT',
37+
'DEFERRABLE',
38+
'DEFLATE',
39+
'DEFRAG',
40+
'DELTA',
41+
'DELTA32K',
42+
'DESC',
43+
'DISABLE',
44+
'DISTINCT',
45+
'DO',
46+
'ELSE',
47+
'EMPTYASNULL',
48+
'ENABLE',
49+
'ENCODE',
50+
'ENCRYPT',
51+
'ENCRYPTION',
52+
'END',
53+
'EXCEPT',
54+
'EXPLICIT',
55+
'FALSE',
56+
'FOR',
57+
'FOREIGN',
58+
'FREEZE',
59+
'FROM',
60+
'FULL',
61+
'GLOBALDICT256',
62+
'GLOBALDICT64K',
63+
'GRANT',
64+
'GROUP',
65+
'GZIP',
66+
'HAVING',
67+
'IDENTITY',
68+
'IGNORE',
69+
'ILIKE',
70+
'IN',
71+
'INITIALLY',
72+
'INNER',
73+
'INTERSECT',
74+
'INTO',
75+
'IS',
76+
'ISNULL',
77+
'JOIN',
78+
'LANGUAGE',
79+
'LEADING',
80+
'LEFT',
81+
'LIKE',
82+
'LIMIT',
83+
'LOCALTIME',
84+
'LOCALTIMESTAMP',
85+
'LUN',
86+
'LUNS',
87+
'LZO',
88+
'LZOP',
89+
'MINUS',
90+
'MOSTLY13',
91+
'MOSTLY32',
92+
'MOSTLY8',
93+
'NATURAL',
94+
'NEW',
95+
'NOT',
96+
'NOTNULL',
97+
'NULL',
98+
'NULLS',
99+
'OFF',
100+
'OFFLINE',
101+
'OFFSET',
102+
'OID',
103+
'OLD',
104+
'ON',
105+
'ONLY',
106+
'OPEN',
107+
'OR',
108+
'ORDER',
109+
'OUTER',
110+
'OVERLAPS',
111+
'PARALLEL',
112+
'PARTITION',
113+
'PERCENT',
114+
'PERMISSIONS',
115+
'PLACING',
116+
'PRIMARY',
117+
'RAW',
118+
'READRATIO',
119+
'RECOVER',
120+
'REFERENCES',
121+
'RESPECT',
122+
'REJECTLOG',
123+
'RESORT',
124+
'RESTORE',
125+
'RIGHT',
126+
'SELECT',
127+
'SESSION_USER',
128+
'SIMILAR',
129+
'SNAPSHOT',
130+
'SOME',
131+
'SYSDATE',
132+
'SYSTEM',
133+
'TABLE',
134+
'TAG',
135+
'TDES',
136+
'TEXT255',
137+
'TEXT32K',
138+
'THEN',
139+
'TIMESTAMP',
140+
'TO',
141+
'TOP',
142+
'TRAILING',
143+
'TRUE',
144+
'TRUNCATECOLUMNS',
145+
'UNION',
146+
'UNIQUE',
147+
'USER',
148+
'USING',
149+
'VERBOSE',
150+
'WALLET',
151+
'WHEN',
152+
'WHERE',
153+
'WITH',
154+
'WITHOUT',
155+
]

0 commit comments

Comments
 (0)