Skip to content

Commit 2187b52

Browse files
authored
Merge pull request #2 from TicketSwap:tobias/move-fields-to-tap-config
move fields selection to tap config to fix flattening
2 parents 0743263 + e86bd15 commit 2187b52

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

meltano.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ plugins:
1818
- structured-logging
1919

2020
select:
21-
- countries.cca3
21+
- countries.*
22+
23+
config:
24+
fields:
25+
- name
26+
- cca2
27+
- cca3
28+
- capital
29+
- region
30+
2231
loaders:
2332
- name: target-jsonl
2433
variant: andyh1203

tap_restcountries/client.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ def get_url_params(
5252
Returns:
5353
A dictionary of URL query parameters.
5454
"""
55-
selected_fields = [k[1] for k,v in self.metadata.items() if v.selected and len(k) == 2]
56-
if len(selected_fields) > 10:
55+
if len(self.config["fields"]) > 10:
5756
raise ValueError("The API has a maximum of 10 fields per request.")
58-
elif len(selected_fields) == 0:
59-
selected_fields = ["cca3"]
60-
return {"fields": ",".join(selected_fields)}
57+
return {"fields": ",".join(self.config["fields"])}

tap_restcountries/tap.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ class TapRestCountries(Tap):
2121

2222
name = "tap-restcountries"
2323

24-
config_jsonschema = {}
24+
config_jsonschema = th.PropertiesList(
25+
th.Property(
26+
"fields",
27+
th.ArrayType(th.StringType),
28+
required=True,
29+
description="List of fields to include in the API response (max 10).",
30+
),
31+
).to_dict()
2532

2633
@override
2734
def discover_streams(self) -> list[streams.RestCountriesStream]:

0 commit comments

Comments
 (0)