i have this - type: ListPartitionRouter ...
# ask-ai
h
i have this - type: ListPartitionRouter values: - 201701;201702;201703 - 201704;201705;201706 - 201707;201708;201709 - 201710;201711;201712 cursor_field: pe in my custom builder is there any way to make it way better since i wan to add another year and month please suggest better solution
k
Your current configuration uses a static list of concatenated year-month strings, which makes it cumbersome to add new years or months. A more scalable and maintainable approach is to use a user input (array) for the partition values. This way, you can easily add or modify the list of periods without editing the connector code. Recommended Solution: 1. Use User Input for Partition Values: Define a user input (e.g.,
periods
) of type array. This allows you (or end users) to specify the list of periods in the Airbyte UI or configuration file. 2. Reference the User Input in the Partition Router: Set the
values
field to reference the user input using Jinja templating. Example:
Copy code
yaml - type: ListPartitionRouter   values: "{{ config['periods'] }}"   cursor_field: pe
- In your connector configuration, define
periods
as an array:
Copy code
json   {     "periods": [       "201701", "201702", "201703",       "201704", "201705", "201706",       "201707", "201708", "201709",       "201710", "201711", "201712",       "201801", "201802", "201803"     ]   }
This approach makes it easy to add new years and months—just update the
periods
array in your configuration, no code changes required. This is the recommended pattern in Airbyte for static partitioning when the set of partitions may change over time or needs to be user-configurable [Partition Router Types](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types). If you want even more flexibility, you could generate the list of periods programmatically outside of Airbyte and pass it in as configuration. Summary: Switch from hardcoding the list in the YAML to referencing a user input array. This is more maintainable and user-friendly for adding new periods in the future.
h
@kapa.ai how shall i add the years with month on the user input?
k
A message from kapa.ai
To add years with months as user input in Airbyte's Connector Builder, you should create a user input of type array. This array should contain each year-month combination as a string (e.g.,
"201701"
,
"201702"
, ...,
"201712"
,
"201801"
, etc.). How to do it: 1. Create a user input: - In the Connector Builder UI, add a new user input. - Name it (for example)
periods
. - Set its type to
array
. 2. Enter the values: - In the configuration or when setting up the source, provide the list of year-month strings you want to use, such as:
Copy code
[        "201701", "201702", "201703",        "201704", "201705", "201706",        "201707", "201708", "201709",        "201710", "201711", "201712",        "201801", "201802", "201803"      ]
3. Reference the user input in your partition router:
Copy code
yaml    - type: ListPartitionRouter      values: "{{ config['periods'] }}"      cursor_field: pe
This way, you can easily add more years and months by simply updating the
periods
array in the user input, without changing the connector code. This approach is recommended for maintainability and flexibility [Partition Router Types](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types). If you need to add more periods, just add more
"YYYYMM"
strings to the array in the user input.
h
@kapa.ai but its saying
The value must match the pattern {{ config['user_input_id'] }}
after i added as an array, how to fix it
k
A message from kapa.ai
The error message
The value must match the pattern {{ config['user_input_id'] }}
suggests that the Connector Builder is expecting a specific pattern or format for the user input, but the input provided does not match it. This often happens if the user input is not correctly set as an array, or if the connector spec or UI is expecting a string instead of an array. How to fix it: 1. Ensure the user input is set to type `array`: - When creating the user input in the Connector Builder UI, make sure you select
array
as the type, not
string
. 2. Reference the user input correctly in your partition router: - In your YAML, use:
Copy code
yaml      values: "{{ config['periods'] }}"
where
periods
is the name of your user input. 3. Check the connector spec (spec.yaml): - The field for your user input should look like this:
Copy code
yaml      periods:        type: array        title: Periods        description: List of year-month strings (e.g., 201701, 201702, ...)        items:          type: string
4. Input the array correctly in the UI or config: - When configuring the source, enter the periods as an array, for example:
Copy code
[        "201701", "201702", "201703",        "201704", "201705", "201706"      ]
If you still see the pattern error: - Double-check that you are not setting a
pattern
property on the array field in your spec. The
pattern
property is only valid for strings, not arrays. If you have a
pattern
on the array field, remove it. Summary: Make sure your user input is of type
array
, your spec does not have a
pattern
on the array field, and you reference it as
{{ config['periods'] }}
in your partition router. This should resolve the pattern error and allow you to use an array of year-month strings as input [Partition Router Types](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#partition-router-types). If you follow these steps and still encounter issues, please share your spec and configuration for further troubleshooting.