FEAT: Add CATERPILLAR_FILE_PATH_WRITE context key (DATA-8693) - #77
Merged
Mayuresh Pawar (Mayureshpawar29) merged 6 commits intoJun 25, 2026
Merged
Conversation
Expose the sanitized full source path as a record context value on the file task's read mode, alongside the existing CATERPILLAR_FILE_NAME_WRITE (base name only). Path segments are slugified individually with "/" preserved between them, so the directory hierarchy survives and can be used in destination paths to avoid same-name collisions when reading nested folders with a recursive glob (e.g. reportType=X/**/**.tsv). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
snehalahire-pattern
requested review from
Mayuresh Pawar (Mayureshpawar29) and
Mahesh Kamble (ma-gk)
June 24, 2026 12:01
- Extract URL scheme stripping in SlugifyFilePath into a stripURLScheme helper. - Hoist the slugified file name into a local variable in the file task. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| In read mode, two values are stored in each record's context: | ||
|
|
||
| - `CATERPILLAR_FILE_NAME_WRITE` — the sanitized base filename. The stem is lowercased with non-alphanumeric characters replaced by underscores, while the extension is preserved and lowercased (e.g. `"Report 1.CSV"` → `"report_1.csv"`). | ||
| - `CATERPILLAR_FILE_PATH_WRITE` — the sanitized full source path with directory hierarchy preserved. Each segment is slugified the same way; the final segment keeps its extension; URL schemes such as `s3://bucket/` are stripped (e.g. `s3://my-bucket/ReportType=A/Folder 1/data.CSV` → `reporttype_a/folder_1/data.csv`). Reference it in the destination of a downstream write task to avoid collisions when reading nested directories with a recursive glob. |
Contributor
There was a problem hiding this comment.
Do we have any use case/example where we would be leveraging this sluggified file path?
Contributor
Author
There was a problem hiding this comment.
Shared the thread over slack
Mayuresh Pawar (Mayureshpawar29)
previously approved these changes
Jun 24, 2026
Show the recursive-glob read + mirrored-write pattern so it's clear how the new context key avoids collisions when sources share a base name across subdirectories. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Exercises CATERPILLAR_FILE_PATH_WRITE end-to-end: recursive glob over nested JSON fixtures, written to a local mirror under /tmp/caterpillar/file_path_write_test/ with directory hierarchy and per-segment slugification preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
prasadlohakpure
approved these changes
Jun 25, 2026
Mayuresh Pawar (Mayureshpawar29)
deleted the
snehal/DATA-8693-file-path-context
branch
June 25, 2026 09:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CATERPILLAR_FILE_PATH_WRITEpopulated by the file task's read mode, alongside the existingCATERPILLAR_FILE_NAME_WRITE(which is unchanged for backward compatibility).textutil.SlugifyFilePathhelper slugifies each path segment individually so the/hierarchy is preserved; URL schemes likes3://bucket/are stripped, the final segment keeps its extension. e.g.s3://my-bucket/ReportType=A/Folder 1/data.CSV→reporttype_a/folder_1/data.csv..../ds={{ ds }}/{{ context "CATERPILLAR_FILE_PATH_WRITE" }}), avoiding same-name collisions when reading nested directories with a recursive glob (e.g.reportType=X/**/**.tsv).ClickUp
DATA-8693
Note on overlapping work
A separate branch
feat/file-path-write-context(commitac18420) takes a different approach to the same ticket: it slugifies the full path into a single flat segment (collapsing/to_) and also wires the new key into the archive/sftp tasks. This PR preserves the directory hierarchy literally, per the ticket's "Path information preserves folder hierarchy" criterion, and is scoped to the file task. Reviewers should pick one approach before merging.Test plan
go build ./...clean (verified locally)go test ./...green (verified locally)reportType=X/**/**.tsvand writing to.../{{ context "CATERPILLAR_FILE_PATH_WRITE" }}; confirm files from different subdirectories no longer overwrite each other in the destination.CATERPILLAR_FILE_NAME_WRITEcontinue to behave identically.🤖 Generated with Claude Code