omniload 0.0.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omniload/conftest.py +72 -0
- omniload/main.py +810 -0
- omniload/src/.gitignore +10 -0
- omniload/src/adjust/__init__.py +108 -0
- omniload/src/adjust/adjust_helpers.py +122 -0
- omniload/src/airtable/__init__.py +84 -0
- omniload/src/allium/__init__.py +128 -0
- omniload/src/anthropic/__init__.py +277 -0
- omniload/src/anthropic/helpers.py +525 -0
- omniload/src/applovin/__init__.py +316 -0
- omniload/src/applovin_max/__init__.py +117 -0
- omniload/src/appsflyer/__init__.py +325 -0
- omniload/src/appsflyer/client.py +110 -0
- omniload/src/appstore/__init__.py +142 -0
- omniload/src/appstore/client.py +126 -0
- omniload/src/appstore/errors.py +15 -0
- omniload/src/appstore/models.py +117 -0
- omniload/src/appstore/resources.py +179 -0
- omniload/src/arrow/__init__.py +81 -0
- omniload/src/asana_source/__init__.py +281 -0
- omniload/src/asana_source/helpers.py +30 -0
- omniload/src/asana_source/settings.py +158 -0
- omniload/src/attio/__init__.py +102 -0
- omniload/src/attio/helpers.py +65 -0
- omniload/src/blob.py +95 -0
- omniload/src/bruin/__init__.py +76 -0
- omniload/src/chess/__init__.py +180 -0
- omniload/src/chess/helpers.py +35 -0
- omniload/src/chess/settings.py +18 -0
- omniload/src/clickup/__init__.py +85 -0
- omniload/src/clickup/helpers.py +47 -0
- omniload/src/collector/spinner.py +43 -0
- omniload/src/couchbase_source/__init__.py +118 -0
- omniload/src/couchbase_source/helpers.py +135 -0
- omniload/src/cursor/__init__.py +83 -0
- omniload/src/cursor/helpers.py +188 -0
- omniload/src/customer_io/__init__.py +486 -0
- omniload/src/customer_io/helpers.py +530 -0
- omniload/src/destinations.py +982 -0
- omniload/src/docebo/__init__.py +589 -0
- omniload/src/docebo/client.py +435 -0
- omniload/src/docebo/helpers.py +97 -0
- omniload/src/dune/__init__.py +104 -0
- omniload/src/dune/helpers.py +108 -0
- omniload/src/dynamodb/__init__.py +86 -0
- omniload/src/elasticsearch/__init__.py +80 -0
- omniload/src/elasticsearch/helpers.py +141 -0
- omniload/src/errors.py +26 -0
- omniload/src/facebook_ads/__init__.py +403 -0
- omniload/src/facebook_ads/exceptions.py +19 -0
- omniload/src/facebook_ads/helpers.py +296 -0
- omniload/src/facebook_ads/settings.py +224 -0
- omniload/src/facebook_ads/utils.py +53 -0
- omniload/src/factory.py +305 -0
- omniload/src/filesystem/__init__.py +133 -0
- omniload/src/filesystem/helpers.py +114 -0
- omniload/src/filesystem/readers.py +187 -0
- omniload/src/filters.py +62 -0
- omniload/src/fireflies/__init__.py +151 -0
- omniload/src/fireflies/helpers.py +753 -0
- omniload/src/fluxx/__init__.py +10013 -0
- omniload/src/fluxx/helpers.py +233 -0
- omniload/src/frankfurter/__init__.py +157 -0
- omniload/src/frankfurter/helpers.py +48 -0
- omniload/src/freshdesk/__init__.py +103 -0
- omniload/src/freshdesk/freshdesk_client.py +151 -0
- omniload/src/freshdesk/settings.py +23 -0
- omniload/src/fundraiseup/__init__.py +95 -0
- omniload/src/fundraiseup/client.py +81 -0
- omniload/src/github/__init__.py +202 -0
- omniload/src/github/helpers.py +207 -0
- omniload/src/github/queries.py +129 -0
- omniload/src/github/settings.py +24 -0
- omniload/src/google_ads/__init__.py +198 -0
- omniload/src/google_ads/field.py +17 -0
- omniload/src/google_ads/metrics.py +254 -0
- omniload/src/google_ads/predicates.py +37 -0
- omniload/src/google_ads/reports.py +411 -0
- omniload/src/google_ads/test_google_ads.py +184 -0
- omniload/src/google_analytics/__init__.py +144 -0
- omniload/src/google_analytics/helpers.py +312 -0
- omniload/src/google_sheets/README.md +95 -0
- omniload/src/google_sheets/__init__.py +166 -0
- omniload/src/google_sheets/helpers/__init__.py +15 -0
- omniload/src/google_sheets/helpers/api_calls.py +160 -0
- omniload/src/google_sheets/helpers/data_processing.py +316 -0
- omniload/src/gorgias/__init__.py +595 -0
- omniload/src/gorgias/helpers.py +166 -0
- omniload/src/hostaway/__init__.py +302 -0
- omniload/src/hostaway/client.py +288 -0
- omniload/src/http/__init__.py +38 -0
- omniload/src/http/readers.py +146 -0
- omniload/src/http_client.py +24 -0
- omniload/src/hubspot/__init__.py +800 -0
- omniload/src/hubspot/helpers.py +417 -0
- omniload/src/hubspot/settings.py +329 -0
- omniload/src/indeed/__init__.py +153 -0
- omniload/src/indeed/helpers.py +228 -0
- omniload/src/influxdb/__init__.py +46 -0
- omniload/src/influxdb/client.py +34 -0
- omniload/src/intercom/__init__.py +142 -0
- omniload/src/intercom/helpers.py +674 -0
- omniload/src/intercom/settings.py +279 -0
- omniload/src/isoc_pulse/__init__.py +159 -0
- omniload/src/jira_source/__init__.py +377 -0
- omniload/src/jira_source/helpers.py +510 -0
- omniload/src/jira_source/settings.py +184 -0
- omniload/src/kafka/__init__.py +120 -0
- omniload/src/kafka/helpers.py +241 -0
- omniload/src/kinesis/__init__.py +153 -0
- omniload/src/kinesis/helpers.py +96 -0
- omniload/src/klaviyo/__init__.py +237 -0
- omniload/src/klaviyo/client.py +212 -0
- omniload/src/klaviyo/helpers.py +19 -0
- omniload/src/linear/__init__.py +634 -0
- omniload/src/linear/helpers.py +111 -0
- omniload/src/linkedin_ads/__init__.py +266 -0
- omniload/src/linkedin_ads/dimension_time_enum.py +17 -0
- omniload/src/linkedin_ads/helpers.py +246 -0
- omniload/src/loader.py +69 -0
- omniload/src/mailchimp/__init__.py +126 -0
- omniload/src/mailchimp/helpers.py +226 -0
- omniload/src/mailchimp/settings.py +164 -0
- omniload/src/masking.py +344 -0
- omniload/src/mixpanel/__init__.py +62 -0
- omniload/src/mixpanel/client.py +104 -0
- omniload/src/monday/__init__.py +246 -0
- omniload/src/monday/helpers.py +392 -0
- omniload/src/monday/settings.py +325 -0
- omniload/src/mongodb/__init__.py +281 -0
- omniload/src/mongodb/helpers.py +975 -0
- omniload/src/notion/__init__.py +69 -0
- omniload/src/notion/helpers/__init__.py +14 -0
- omniload/src/notion/helpers/client.py +178 -0
- omniload/src/notion/helpers/database.py +92 -0
- omniload/src/notion/settings.py +17 -0
- omniload/src/partition.py +32 -0
- omniload/src/personio/__init__.py +345 -0
- omniload/src/personio/helpers.py +100 -0
- omniload/src/phantombuster/__init__.py +65 -0
- omniload/src/phantombuster/client.py +87 -0
- omniload/src/pinterest/__init__.py +82 -0
- omniload/src/pipedrive/__init__.py +212 -0
- omniload/src/pipedrive/helpers/__init__.py +37 -0
- omniload/src/pipedrive/helpers/custom_fields_munger.py +116 -0
- omniload/src/pipedrive/helpers/pages.py +129 -0
- omniload/src/pipedrive/settings.py +41 -0
- omniload/src/pipedrive/typing.py +17 -0
- omniload/src/plusvibeai/__init__.py +335 -0
- omniload/src/plusvibeai/helpers.py +544 -0
- omniload/src/plusvibeai/settings.py +252 -0
- omniload/src/primer/__init__.py +45 -0
- omniload/src/primer/helpers.py +79 -0
- omniload/src/quickbooks/__init__.py +117 -0
- omniload/src/reddit_ads/__init__.py +183 -0
- omniload/src/reddit_ads/helpers.py +232 -0
- omniload/src/resource.py +40 -0
- omniload/src/revenuecat/__init__.py +83 -0
- omniload/src/revenuecat/helpers.py +237 -0
- omniload/src/salesforce/__init__.py +170 -0
- omniload/src/salesforce/helpers.py +78 -0
- omniload/src/shopify/__init__.py +1953 -0
- omniload/src/shopify/exceptions.py +17 -0
- omniload/src/shopify/helpers.py +202 -0
- omniload/src/shopify/settings.py +19 -0
- omniload/src/slack/__init__.py +290 -0
- omniload/src/slack/helpers.py +218 -0
- omniload/src/slack/settings.py +36 -0
- omniload/src/smartsheets/__init__.py +82 -0
- omniload/src/snapchat_ads/__init__.py +455 -0
- omniload/src/snapchat_ads/client.py +72 -0
- omniload/src/snapchat_ads/helpers.py +630 -0
- omniload/src/snapchat_ads/settings.py +130 -0
- omniload/src/socrata_source/__init__.py +83 -0
- omniload/src/socrata_source/helpers.py +85 -0
- omniload/src/socrata_source/settings.py +8 -0
- omniload/src/solidgate/__init__.py +219 -0
- omniload/src/solidgate/helpers.py +154 -0
- omniload/src/sources.py +5408 -0
- omniload/src/sql_database/__init__.py +0 -0
- omniload/src/sql_database/callbacks.py +66 -0
- omniload/src/stripe_analytics/__init__.py +183 -0
- omniload/src/stripe_analytics/helpers.py +386 -0
- omniload/src/stripe_analytics/settings.py +80 -0
- omniload/src/table_definition.py +15 -0
- omniload/src/testdata/fakebqcredentials.json +14 -0
- omniload/src/tiktok_ads/__init__.py +150 -0
- omniload/src/tiktok_ads/tiktok_helpers.py +130 -0
- omniload/src/time.py +11 -0
- omniload/src/trustpilot/__init__.py +48 -0
- omniload/src/trustpilot/client.py +48 -0
- omniload/src/version.py +6 -0
- omniload/src/wise/__init__.py +68 -0
- omniload/src/wise/client.py +63 -0
- omniload/src/zendesk/__init__.py +480 -0
- omniload/src/zendesk/helpers/__init__.py +39 -0
- omniload/src/zendesk/helpers/api_helpers.py +119 -0
- omniload/src/zendesk/helpers/credentials.py +68 -0
- omniload/src/zendesk/helpers/talk_api.py +132 -0
- omniload/src/zendesk/settings.py +71 -0
- omniload/src/zoom/__init__.py +99 -0
- omniload/src/zoom/helpers.py +102 -0
- omniload/testdata/.gitignore +2 -0
- omniload/testdata/create_replace.csv +21 -0
- omniload/testdata/delete_insert_expected.csv +6 -0
- omniload/testdata/delete_insert_part1.csv +5 -0
- omniload/testdata/delete_insert_part2.csv +6 -0
- omniload/testdata/merge_expected.csv +5 -0
- omniload/testdata/merge_part1.csv +4 -0
- omniload/testdata/merge_part2.csv +5 -0
- omniload/tests/unit/test_smartsheets.py +133 -0
- omniload-0.0.0.dev0.dist-info/METADATA +439 -0
- omniload-0.0.0.dev0.dist-info/RECORD +218 -0
- omniload-0.0.0.dev0.dist-info/WHEEL +4 -0
- omniload-0.0.0.dev0.dist-info/entry_points.txt +2 -0
- omniload-0.0.0.dev0.dist-info/licenses/LICENSE.Apache-2.0 +201 -0
- omniload-0.0.0.dev0.dist-info/licenses/LICENSE.md +21 -0
- omniload-0.0.0.dev0.dist-info/licenses/NOTICE +35 -0
omniload/src/factory.py
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
from typing import Dict, Protocol, Type
|
|
2
|
+
from urllib.parse import urlparse
|
|
3
|
+
|
|
4
|
+
from dlt.common.destination import Destination
|
|
5
|
+
|
|
6
|
+
from omniload.src.destinations import (
|
|
7
|
+
AthenaDestination,
|
|
8
|
+
BigQueryDestination,
|
|
9
|
+
ClickhouseDestination,
|
|
10
|
+
CrateDBDestination,
|
|
11
|
+
CsvDestination,
|
|
12
|
+
DatabricksDestination,
|
|
13
|
+
DuckDBDestination,
|
|
14
|
+
ElasticsearchDestination,
|
|
15
|
+
GCSDestination,
|
|
16
|
+
MongoDBDestination,
|
|
17
|
+
MotherduckDestination,
|
|
18
|
+
MsSQLDestination,
|
|
19
|
+
MySqlDestination,
|
|
20
|
+
PostgresDestination,
|
|
21
|
+
RedshiftDestination,
|
|
22
|
+
S3Destination,
|
|
23
|
+
SnowflakeDestination,
|
|
24
|
+
SqliteDestination,
|
|
25
|
+
SynapseDestination,
|
|
26
|
+
TrinoDestination,
|
|
27
|
+
)
|
|
28
|
+
from omniload.src.sources import (
|
|
29
|
+
AdjustSource,
|
|
30
|
+
AirtableSource,
|
|
31
|
+
AlliumSource,
|
|
32
|
+
AnthropicSource,
|
|
33
|
+
AppleAppStoreSource,
|
|
34
|
+
ApplovinMaxSource,
|
|
35
|
+
AppLovinSource,
|
|
36
|
+
AppsflyerSource,
|
|
37
|
+
ArrowMemoryMappedSource,
|
|
38
|
+
AsanaSource,
|
|
39
|
+
AttioSource,
|
|
40
|
+
BruinSource,
|
|
41
|
+
ChessSource,
|
|
42
|
+
ClickupSource,
|
|
43
|
+
CouchbaseSource,
|
|
44
|
+
CursorSource,
|
|
45
|
+
CustomerIoSource,
|
|
46
|
+
DoceboSource,
|
|
47
|
+
DuneSource,
|
|
48
|
+
DynamoDBSource,
|
|
49
|
+
ElasticsearchSource,
|
|
50
|
+
FacebookAdsSource,
|
|
51
|
+
FirefliesSource,
|
|
52
|
+
FluxxSource,
|
|
53
|
+
FrankfurterSource,
|
|
54
|
+
FreshdeskSource,
|
|
55
|
+
FundraiseupSource,
|
|
56
|
+
GCSSource,
|
|
57
|
+
GitHubSource,
|
|
58
|
+
GoogleAdsSource,
|
|
59
|
+
GoogleAnalyticsSource,
|
|
60
|
+
GoogleSheetsSource,
|
|
61
|
+
GorgiasSource,
|
|
62
|
+
HostawaySource,
|
|
63
|
+
HttpSource,
|
|
64
|
+
HubspotSource,
|
|
65
|
+
IndeedSource,
|
|
66
|
+
InfluxDBSource,
|
|
67
|
+
IntercomSource,
|
|
68
|
+
IsocPulseSource,
|
|
69
|
+
JiraSource,
|
|
70
|
+
KafkaSource,
|
|
71
|
+
KinesisSource,
|
|
72
|
+
KlaviyoSource,
|
|
73
|
+
LinearSource,
|
|
74
|
+
LinkedInAdsSource,
|
|
75
|
+
LocalCsvSource,
|
|
76
|
+
MailchimpSource,
|
|
77
|
+
MixpanelSource,
|
|
78
|
+
MondaySource,
|
|
79
|
+
MongoDbSource,
|
|
80
|
+
NotionSource,
|
|
81
|
+
PersonioSource,
|
|
82
|
+
PhantombusterSource,
|
|
83
|
+
PinterestSource,
|
|
84
|
+
PipedriveSource,
|
|
85
|
+
PlusVibeAISource,
|
|
86
|
+
PrimerSource,
|
|
87
|
+
QuickBooksSource,
|
|
88
|
+
RedditAdsSource,
|
|
89
|
+
RevenueCatSource,
|
|
90
|
+
S3Source,
|
|
91
|
+
SalesforceSource,
|
|
92
|
+
SFTPSource,
|
|
93
|
+
ShopifySource,
|
|
94
|
+
SlackSource,
|
|
95
|
+
SmartsheetSource,
|
|
96
|
+
SnapchatAdsSource,
|
|
97
|
+
SocrataSource,
|
|
98
|
+
SolidgateSource,
|
|
99
|
+
SqlSource,
|
|
100
|
+
StripeAnalyticsSource,
|
|
101
|
+
TikTokSource,
|
|
102
|
+
TrustpilotSource,
|
|
103
|
+
WiseSource,
|
|
104
|
+
ZendeskSource,
|
|
105
|
+
ZoomSource,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
SQL_SOURCE_SCHEMES = [
|
|
109
|
+
"bigquery",
|
|
110
|
+
"crate",
|
|
111
|
+
"cratedb",
|
|
112
|
+
"duckdb",
|
|
113
|
+
"mssql",
|
|
114
|
+
"mssql+pyodbc",
|
|
115
|
+
"mysql",
|
|
116
|
+
"mysql+pymysql",
|
|
117
|
+
"mysql+mysqlconnector",
|
|
118
|
+
"md",
|
|
119
|
+
"motherduck",
|
|
120
|
+
"postgres",
|
|
121
|
+
"postgresql",
|
|
122
|
+
"postgresql+psycopg2",
|
|
123
|
+
"redshift",
|
|
124
|
+
"redshift+psycopg2",
|
|
125
|
+
"snowflake",
|
|
126
|
+
"sqlite",
|
|
127
|
+
"oracle",
|
|
128
|
+
"oracle+cx_oracle",
|
|
129
|
+
"oracle+oracledb",
|
|
130
|
+
"hana",
|
|
131
|
+
"clickhouse",
|
|
132
|
+
"databricks",
|
|
133
|
+
"db2",
|
|
134
|
+
"spanner",
|
|
135
|
+
"trino",
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class SourceProtocol(Protocol):
|
|
140
|
+
def dlt_source(self, uri: str, table: str, **kwargs):
|
|
141
|
+
pass
|
|
142
|
+
|
|
143
|
+
def handles_incrementality(self) -> bool:
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class DestinationProtocol(Protocol):
|
|
148
|
+
def dlt_dest(self, uri: str, **kwargs) -> Destination:
|
|
149
|
+
pass
|
|
150
|
+
|
|
151
|
+
def dlt_run_params(self, uri: str, table: str, **kwargs):
|
|
152
|
+
pass
|
|
153
|
+
|
|
154
|
+
def post_load(self) -> None:
|
|
155
|
+
pass
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def parse_scheme_from_uri(uri: str) -> str:
|
|
159
|
+
parsed = urlparse(uri)
|
|
160
|
+
if parsed.scheme != "":
|
|
161
|
+
return parsed.scheme
|
|
162
|
+
|
|
163
|
+
uri_parts = uri.split("://")
|
|
164
|
+
if len(uri_parts) > 1:
|
|
165
|
+
return uri_parts[0]
|
|
166
|
+
|
|
167
|
+
raise ValueError(f"Could not parse scheme from uri: {uri}")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class SourceDestinationFactory:
|
|
171
|
+
source_scheme: str
|
|
172
|
+
destination_scheme: str
|
|
173
|
+
sources: Dict[str, Type[SourceProtocol]] = {
|
|
174
|
+
"allium": AlliumSource,
|
|
175
|
+
"anthropic": AnthropicSource,
|
|
176
|
+
"bruin": BruinSource,
|
|
177
|
+
"csv": LocalCsvSource,
|
|
178
|
+
"couchbase": CouchbaseSource,
|
|
179
|
+
"cursor": CursorSource,
|
|
180
|
+
"docebo": DoceboSource,
|
|
181
|
+
"dune": DuneSource,
|
|
182
|
+
"http": HttpSource,
|
|
183
|
+
"https": HttpSource,
|
|
184
|
+
"mongodb": MongoDbSource,
|
|
185
|
+
"mongodb+srv": MongoDbSource,
|
|
186
|
+
"notion": NotionSource,
|
|
187
|
+
"gsheets": GoogleSheetsSource,
|
|
188
|
+
"shopify": ShopifySource,
|
|
189
|
+
"gorgias": GorgiasSource,
|
|
190
|
+
"github": GitHubSource,
|
|
191
|
+
"chess": ChessSource,
|
|
192
|
+
"stripe": StripeAnalyticsSource,
|
|
193
|
+
"facebookads": FacebookAdsSource,
|
|
194
|
+
"fluxx": FluxxSource,
|
|
195
|
+
"slack": SlackSource,
|
|
196
|
+
"hostaway": HostawaySource,
|
|
197
|
+
"hubspot": HubspotSource,
|
|
198
|
+
"indeed": IndeedSource,
|
|
199
|
+
"intercom": IntercomSource,
|
|
200
|
+
"jira": JiraSource,
|
|
201
|
+
"airtable": AirtableSource,
|
|
202
|
+
"klaviyo": KlaviyoSource,
|
|
203
|
+
"mixpanel": MixpanelSource,
|
|
204
|
+
"appsflyer": AppsflyerSource,
|
|
205
|
+
"kafka": KafkaSource,
|
|
206
|
+
"adjust": AdjustSource,
|
|
207
|
+
"zendesk": ZendeskSource,
|
|
208
|
+
"mmap": ArrowMemoryMappedSource,
|
|
209
|
+
"s3": S3Source,
|
|
210
|
+
"dynamodb": DynamoDBSource,
|
|
211
|
+
"asana": AsanaSource,
|
|
212
|
+
"tiktok": TikTokSource,
|
|
213
|
+
"googleanalytics": GoogleAnalyticsSource,
|
|
214
|
+
"googleads": GoogleAdsSource,
|
|
215
|
+
"appstore": AppleAppStoreSource,
|
|
216
|
+
"gs": GCSSource,
|
|
217
|
+
"linkedinads": LinkedInAdsSource,
|
|
218
|
+
"linear": LinearSource,
|
|
219
|
+
"applovin": AppLovinSource,
|
|
220
|
+
"applovinmax": ApplovinMaxSource,
|
|
221
|
+
"salesforce": SalesforceSource,
|
|
222
|
+
"personio": PersonioSource,
|
|
223
|
+
"kinesis": KinesisSource,
|
|
224
|
+
"pipedrive": PipedriveSource,
|
|
225
|
+
"frankfurter": FrankfurterSource,
|
|
226
|
+
"freshdesk": FreshdeskSource,
|
|
227
|
+
"fundraiseup": FundraiseupSource,
|
|
228
|
+
"trustpilot": TrustpilotSource,
|
|
229
|
+
"phantombuster": PhantombusterSource,
|
|
230
|
+
"elasticsearch": ElasticsearchSource,
|
|
231
|
+
"attio": AttioSource,
|
|
232
|
+
"solidgate": SolidgateSource,
|
|
233
|
+
"quickbooks": QuickBooksSource,
|
|
234
|
+
"isoc-pulse": IsocPulseSource,
|
|
235
|
+
"smartsheet": SmartsheetSource,
|
|
236
|
+
"sftp": SFTPSource,
|
|
237
|
+
"pinterest": PinterestSource,
|
|
238
|
+
"redditads": RedditAdsSource,
|
|
239
|
+
"revenuecat": RevenueCatSource,
|
|
240
|
+
"socrata": SocrataSource,
|
|
241
|
+
"snapchatads": SnapchatAdsSource,
|
|
242
|
+
"zoom": ZoomSource,
|
|
243
|
+
"clickup": ClickupSource,
|
|
244
|
+
"influxdb": InfluxDBSource,
|
|
245
|
+
"wise": WiseSource,
|
|
246
|
+
"plusvibeai": PlusVibeAISource,
|
|
247
|
+
"monday": MondaySource,
|
|
248
|
+
"mailchimp": MailchimpSource,
|
|
249
|
+
"primer": PrimerSource,
|
|
250
|
+
"fireflies": FirefliesSource,
|
|
251
|
+
"customerio": CustomerIoSource,
|
|
252
|
+
}
|
|
253
|
+
destinations: Dict[str, Type[DestinationProtocol]] = {
|
|
254
|
+
"bigquery": BigQueryDestination,
|
|
255
|
+
"cratedb": CrateDBDestination,
|
|
256
|
+
"databricks": DatabricksDestination,
|
|
257
|
+
"duckdb": DuckDBDestination,
|
|
258
|
+
"motherduck": MotherduckDestination,
|
|
259
|
+
"md": MotherduckDestination,
|
|
260
|
+
"mssql": MsSQLDestination,
|
|
261
|
+
"postgres": PostgresDestination,
|
|
262
|
+
"postgresql": PostgresDestination,
|
|
263
|
+
"postgresql+psycopg2": PostgresDestination,
|
|
264
|
+
"redshift": RedshiftDestination,
|
|
265
|
+
"redshift+psycopg2": RedshiftDestination,
|
|
266
|
+
"redshift+redshift_connector": RedshiftDestination,
|
|
267
|
+
"snowflake": SnowflakeDestination,
|
|
268
|
+
"synapse": SynapseDestination,
|
|
269
|
+
"csv": CsvDestination,
|
|
270
|
+
"athena": AthenaDestination,
|
|
271
|
+
"clickhouse+native": ClickhouseDestination,
|
|
272
|
+
"clickhouse": ClickhouseDestination,
|
|
273
|
+
"elasticsearch": ElasticsearchDestination,
|
|
274
|
+
"mongodb": MongoDBDestination,
|
|
275
|
+
"mongodb+srv": MongoDBDestination,
|
|
276
|
+
"s3": S3Destination,
|
|
277
|
+
"gs": GCSDestination,
|
|
278
|
+
"sqlite": SqliteDestination,
|
|
279
|
+
"mysql": MySqlDestination,
|
|
280
|
+
"mysql+pymysql": MySqlDestination,
|
|
281
|
+
"trino": TrinoDestination,
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
def __init__(self, source_uri: str, destination_uri: str):
|
|
285
|
+
self.source_uri = source_uri
|
|
286
|
+
self.source_scheme = parse_scheme_from_uri(source_uri)
|
|
287
|
+
|
|
288
|
+
self.destination_uri = destination_uri
|
|
289
|
+
self.destination_scheme = parse_scheme_from_uri(destination_uri)
|
|
290
|
+
|
|
291
|
+
def get_source(self) -> SourceProtocol:
|
|
292
|
+
if self.source_scheme in SQL_SOURCE_SCHEMES:
|
|
293
|
+
return SqlSource()
|
|
294
|
+
elif self.source_scheme in self.sources:
|
|
295
|
+
return self.sources[self.source_scheme]()
|
|
296
|
+
else:
|
|
297
|
+
raise ValueError(f"Unsupported source scheme: {self.source_scheme}")
|
|
298
|
+
|
|
299
|
+
def get_destination(self) -> DestinationProtocol:
|
|
300
|
+
if self.destination_scheme in self.destinations:
|
|
301
|
+
return self.destinations[self.destination_scheme]()
|
|
302
|
+
else:
|
|
303
|
+
raise ValueError(
|
|
304
|
+
f"Unsupported destination scheme: {self.destination_scheme}"
|
|
305
|
+
)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Copyright 2022-2025 ScaleVector
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Reads files in s3, gs or azure buckets using fsspec and provides convenience resources for chunked reading of various file formats"""
|
|
16
|
+
|
|
17
|
+
from typing import Iterator, List, Optional, Tuple, Union
|
|
18
|
+
|
|
19
|
+
import dlt
|
|
20
|
+
from dlt.sources import DltResource
|
|
21
|
+
from dlt.sources.credentials import FileSystemCredentials
|
|
22
|
+
from dlt.sources.filesystem import FileItem, FileItemDict, fsspec_filesystem, glob_files
|
|
23
|
+
|
|
24
|
+
from .helpers import (
|
|
25
|
+
AbstractFileSystem,
|
|
26
|
+
FilesystemConfigurationResource,
|
|
27
|
+
)
|
|
28
|
+
from .readers import (
|
|
29
|
+
ReadersSource,
|
|
30
|
+
_read_csv,
|
|
31
|
+
_read_csv_duckdb,
|
|
32
|
+
_read_csv_headless,
|
|
33
|
+
_read_jsonl,
|
|
34
|
+
_read_parquet,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dlt.source(_impl_cls=ReadersSource, spec=FilesystemConfigurationResource)
|
|
39
|
+
def readers(
|
|
40
|
+
bucket_url: str,
|
|
41
|
+
credentials: Union[FileSystemCredentials, AbstractFileSystem],
|
|
42
|
+
file_glob: Optional[str] = "*",
|
|
43
|
+
) -> Tuple[DltResource, ...]:
|
|
44
|
+
"""This source provides a few resources that are chunked file readers. Readers can be further parametrized before use
|
|
45
|
+
read_csv(chunksize, **pandas_kwargs)
|
|
46
|
+
read_jsonl(chunksize)
|
|
47
|
+
read_parquet(chunksize)
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
bucket_url (str): The url to the bucket.
|
|
51
|
+
credentials (FileSystemCredentials | AbstractFilesystem): The credentials to the filesystem of fsspec `AbstractFilesystem` instance.
|
|
52
|
+
file_glob (str, optional): The filter to apply to the files in glob format. by default lists all files in bucket_url non-recursively
|
|
53
|
+
"""
|
|
54
|
+
filesystem_resource = filesystem(bucket_url, credentials, file_glob=file_glob)
|
|
55
|
+
|
|
56
|
+
# NOTE: incremental support is disabled until we can figure out
|
|
57
|
+
# how to support incremental loads per matching file, rather
|
|
58
|
+
# than a blanket threshold.
|
|
59
|
+
#
|
|
60
|
+
# filesystem_resource.apply_hints(
|
|
61
|
+
# incremental=dlt.sources.incremental("modification_date"),
|
|
62
|
+
# )
|
|
63
|
+
return (
|
|
64
|
+
filesystem_resource
|
|
65
|
+
| dlt.transformer(name="read_csv", max_table_nesting=0)(_read_csv),
|
|
66
|
+
filesystem_resource
|
|
67
|
+
| dlt.transformer(name="read_csv_headless", max_table_nesting=0)(
|
|
68
|
+
_read_csv_headless
|
|
69
|
+
),
|
|
70
|
+
filesystem_resource
|
|
71
|
+
| dlt.transformer(name="read_jsonl", max_table_nesting=0)(_read_jsonl),
|
|
72
|
+
filesystem_resource
|
|
73
|
+
| dlt.transformer(name="read_parquet", max_table_nesting=0)(_read_parquet),
|
|
74
|
+
filesystem_resource
|
|
75
|
+
| dlt.transformer(name="read_csv_duckdb", max_table_nesting=0)(
|
|
76
|
+
_read_csv_duckdb
|
|
77
|
+
),
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dlt.resource(
|
|
82
|
+
primary_key="file_url", spec=FilesystemConfigurationResource, standalone=True
|
|
83
|
+
)
|
|
84
|
+
def filesystem(
|
|
85
|
+
bucket_url: str = dlt.secrets.value,
|
|
86
|
+
credentials: Union[FileSystemCredentials, AbstractFileSystem] = dlt.secrets.value,
|
|
87
|
+
file_glob: Optional[str] = "*",
|
|
88
|
+
files_per_page: int = 100,
|
|
89
|
+
extract_content: bool = True,
|
|
90
|
+
) -> Iterator[List[FileItem]]:
|
|
91
|
+
"""This resource lists files in `bucket_url` using `file_glob` pattern. The files are yielded as FileItem which also
|
|
92
|
+
provide methods to open and read file data. It should be combined with transformers that further process (ie. load files)
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
bucket_url (str): The url to the bucket.
|
|
96
|
+
credentials (FileSystemCredentials | AbstractFilesystem): The credentials to the filesystem of fsspec `AbstractFilesystem` instance.
|
|
97
|
+
file_glob (str, optional): The filter to apply to the files in glob format. by default lists all files in bucket_url non-recursively
|
|
98
|
+
files_per_page (int, optional): The number of files to process at once, defaults to 100.
|
|
99
|
+
extract_content (bool, optional): If true, the content of the file will be extracted if
|
|
100
|
+
false it will return a fsspec file, defaults to False.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
Iterator[List[FileItem]]: The list of files.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
if isinstance(credentials, AbstractFileSystem):
|
|
107
|
+
fs_client = credentials
|
|
108
|
+
else:
|
|
109
|
+
fs_client = fsspec_filesystem(bucket_url, credentials)[0]
|
|
110
|
+
|
|
111
|
+
files_chunk: List[FileItem] = []
|
|
112
|
+
for file_model in glob_files(fs_client, bucket_url, file_glob):
|
|
113
|
+
file_dict = FileItemDict(file_model, credentials)
|
|
114
|
+
if extract_content:
|
|
115
|
+
file_dict["file_content"] = file_dict.read_bytes()
|
|
116
|
+
files_chunk.append(file_dict) # type: ignore
|
|
117
|
+
# wait for the chunk to be full
|
|
118
|
+
if len(files_chunk) >= files_per_page:
|
|
119
|
+
yield files_chunk
|
|
120
|
+
files_chunk = []
|
|
121
|
+
if files_chunk:
|
|
122
|
+
yield files_chunk
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
read_csv = dlt.transformer(standalone=True, max_table_nesting=0)(_read_csv)
|
|
126
|
+
read_csv_headless = dlt.transformer(standalone=True, max_table_nesting=0)(
|
|
127
|
+
_read_csv_headless
|
|
128
|
+
)
|
|
129
|
+
read_jsonl = dlt.transformer(standalone=True, max_table_nesting=0)(_read_jsonl)
|
|
130
|
+
read_parquet = dlt.transformer(standalone=True, max_table_nesting=0)(_read_parquet)
|
|
131
|
+
read_csv_duckdb = dlt.transformer(standalone=True, max_table_nesting=0)(
|
|
132
|
+
_read_csv_duckdb
|
|
133
|
+
)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Copyright 2022-2025 ScaleVector
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Helpers for the filesystem resource."""
|
|
16
|
+
|
|
17
|
+
from typing import Any, Dict, Iterable, List, Optional, Type, Union
|
|
18
|
+
|
|
19
|
+
import dlt
|
|
20
|
+
from dlt.common.configuration import resolve_type
|
|
21
|
+
from dlt.common.typing import TDataItem
|
|
22
|
+
from dlt.sources import DltResource
|
|
23
|
+
from dlt.sources.config import configspec, with_config
|
|
24
|
+
from dlt.sources.credentials import (
|
|
25
|
+
CredentialsConfiguration,
|
|
26
|
+
FilesystemConfiguration,
|
|
27
|
+
FileSystemCredentials,
|
|
28
|
+
)
|
|
29
|
+
from dlt.sources.filesystem import fsspec_filesystem
|
|
30
|
+
from fsspec import AbstractFileSystem # type: ignore
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@configspec
|
|
34
|
+
class FilesystemConfigurationResource(FilesystemConfiguration):
|
|
35
|
+
credentials: Union[FileSystemCredentials, AbstractFileSystem] = None
|
|
36
|
+
file_glob: Optional[str] = "*"
|
|
37
|
+
files_per_page: int = 100
|
|
38
|
+
extract_content: bool = False
|
|
39
|
+
|
|
40
|
+
@resolve_type("credentials")
|
|
41
|
+
def resolve_credentials_type(self) -> Type[CredentialsConfiguration]:
|
|
42
|
+
# use known credentials or empty credentials for unknown protocol
|
|
43
|
+
return Union[
|
|
44
|
+
self.PROTOCOL_CREDENTIALS.get(self.protocol)
|
|
45
|
+
or Optional[CredentialsConfiguration],
|
|
46
|
+
AbstractFileSystem,
|
|
47
|
+
] # type: ignore[return-value]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def fsspec_from_resource(filesystem_instance: DltResource) -> AbstractFileSystem:
|
|
51
|
+
"""Extract authorized fsspec client from a filesystem resource"""
|
|
52
|
+
|
|
53
|
+
@with_config(
|
|
54
|
+
spec=FilesystemConfiguration,
|
|
55
|
+
sections=("sources", filesystem_instance.section, filesystem_instance.name),
|
|
56
|
+
)
|
|
57
|
+
def _get_fsspec(
|
|
58
|
+
bucket_url: str, credentials: Optional[FileSystemCredentials]
|
|
59
|
+
) -> AbstractFileSystem:
|
|
60
|
+
return fsspec_filesystem(bucket_url, credentials)[0]
|
|
61
|
+
|
|
62
|
+
return _get_fsspec(
|
|
63
|
+
filesystem_instance.explicit_args.get("bucket_url", dlt.config.value),
|
|
64
|
+
filesystem_instance.explicit_args.get("credentials", dlt.secrets.value),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def add_columns(columns: List[str], rows: List[List[Any]]) -> List[Dict[str, Any]]:
|
|
69
|
+
"""Adds column names to the given rows.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
columns (List[str]): The column names.
|
|
73
|
+
rows (List[List[Any]]): The rows.
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
List[Dict[str, Any]]: The rows with column names.
|
|
77
|
+
"""
|
|
78
|
+
result = []
|
|
79
|
+
for row in rows:
|
|
80
|
+
result.append(dict(zip(columns, row)))
|
|
81
|
+
|
|
82
|
+
return result
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def fetch_arrow(file_data, chunk_size: int) -> Iterable[TDataItem]: # type: ignore
|
|
86
|
+
"""Fetches data from the given CSV file.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
file_data (DuckDBPyRelation): The CSV file data.
|
|
90
|
+
chunk_size (int): The number of rows to read at once.
|
|
91
|
+
|
|
92
|
+
Yields:
|
|
93
|
+
Iterable[TDataItem]: Data items, read from the given CSV file.
|
|
94
|
+
"""
|
|
95
|
+
batcher = file_data.fetch_arrow_reader(batch_size=chunk_size)
|
|
96
|
+
yield from batcher
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def fetch_json(file_data, chunk_size: int) -> List[Dict[str, Any]]: # type: ignore
|
|
100
|
+
"""Fetches data from the given CSV file.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
file_data (DuckDBPyRelation): The CSV file data.
|
|
104
|
+
chunk_size (int): The number of rows to read at once.
|
|
105
|
+
|
|
106
|
+
Yields:
|
|
107
|
+
Iterable[TDataItem]: Data items, read from the given CSV file.
|
|
108
|
+
"""
|
|
109
|
+
while True:
|
|
110
|
+
batch = file_data.fetchmany(chunk_size)
|
|
111
|
+
if not batch:
|
|
112
|
+
break
|
|
113
|
+
|
|
114
|
+
yield add_columns(file_data.columns, batch)
|