Area: Ingestion
Sub-Area: S3 Source
Applies to: OSS + Cloud
Issue
You changed an S3 recipe to create datasets at the folder level instead of one dataset per file. The ingestion now fails, or it still creates one dataset per file.
You Might Be Asking
- Why does my S3 recipe fail with
path_spec.include cannot contain '**'? - How do I make one dataset per folder instead of one per file?
- What is the source type for S3?
- How do I catalog folders without creating datasets?
Cause
The recipe uses settings the S3 source does not accept:
-
Wrong source type. The S3 source type is
s3. There is nos3-data-lakesource type. -
**ininclude. Anincludethat contains**fails withpath_spec.include cannot contain '**', unless you setallow_double_stars: trueon that path spec. The one exception: withautodetect_partitionson (the default), anincludethat ends in{table}or{table}/is allowed. -
No
{table}ininclude. Without{table}, each file becomes its own dataset. The{table}placeholder marks the folder that becomes one dataset. -
{folder}intable_name.{folder}is reserved and you must not use it. Iftable_nameuses a named variable that is not ininclude, validation fails withNot all named variables used in path_spec.table_name ... are specified in path_spec.include .... -
AWS settings in the wrong place. For the S3 source, AWS credentials and region go in the
aws_configblock. Ifaws_configis not set for thes3platform, ingestion fails withAWS config is required for S3 file sources.
Solution
One dataset per folder
Put {table} in include where the dataset folder is. Do not set table_name. It defaults to {table}.
source:
type: s3
config:
path_specs:
- include: "s3://bucket-name/data/{table}/*.parquet"
aws_config:
aws_region: "us-east-1"
aws_access_key_id: "<access key id>"
aws_secret_access_key: "<secret access key>"
If the folder holds partitions in key=value folders such as year=2024, end the include at the table folder. The source detects the partitions for you:
path_specs:
- include: "s3://bucket-name/data/{table}/"
You can also use aws_role or aws_profile in aws_config instead of access keys.
Catalog folders without creating datasets
Set emit_folders_only: true on the path spec. Each matching folder becomes a container and no datasets are created. The folder depth comes from the * levels in include. The include must end at a folder. It cannot contain {table} or **. In this mode, table_name, default_extension, non-default file_types and tables_filter_pattern are rejected.
source:
type: s3
config:
path_specs:
- include: "s3://bucket-name/data/*/"
emit_folders_only: true
aws_config:
aws_region: "us-east-1"
emit_folders_only is present in CLI 1.7.0.20. Upgrade to the latest release if your CLI does not accept it.
Check the recipe before you run it
Use datahub recipe probe to check what a recipe would ingest before you run it. See Checking path_specs before you ingest.
Large buckets
The traversal_method setting on a path spec controls how folders are traversed. The default is MAX, which traverses the folder with the max value. MIN_MAX finds the min and max values. ALL traverses all the folders. See Partitioned dataset support.
IAM permissions
The documented minimum actions are s3:ListBucket, s3:GetBucketLocation and s3:GetObject. s3:GetObject is needed for schema inference. A wildcard bucket in include also needs s3:ListAllMyBuckets.