Skip to content

Add DataWeave to DataSonnet transpiler in camel-jbang#22157

Open
gnodet wants to merge 3 commits intomainfrom
worktree-dataweave-to-datasonnet
Open

Add DataWeave to DataSonnet transpiler in camel-jbang#22157
gnodet wants to merge 3 commits intomainfrom
worktree-dataweave-to-datasonnet

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 20, 2026

Summary

Add a camel transform dataweave CLI command that converts MuleSoft DataWeave 2.0 scripts into equivalent DataSonnet .ds files, reducing the effort of migrating Mule integrations to Apache Camel.

  • Hand-written recursive descent parser for DataWeave 2.0 syntax (header, field access, operators, lambdas, collection ops, type coercion, etc.)
  • AST-based conversion to DataSonnet using Camel's CML functions (cml.defaultVal, cml.toInteger, cml.nowFmt, etc.) and camel.libsonnet helpers
  • Handles ~80% of common patterns mechanically; flags unsupported constructs with // TODO comments
  • 43 unit tests covering field access, operators, type coercion, null handling, collections (map/filter/reduce with acc/item swap), string ops, full script conversion

CLI usage

camel transform dataweave --input flow.dwl --output flow.ds
camel transform dataweave --input src/main/mule/ --output src/main/resources/
camel transform dataweave -e 'payload.name default "unknown"'

Depends on

Test plan

  • 43 unit tests in DataWeaveConverterTest covering all conversion patterns
  • Full camel-jbang-core test suite passes (289 tests)
  • Manual testing with real-world DataWeave scripts from Mule projects

Add a `camel transform dataweave` CLI command that converts MuleSoft
DataWeave 2.0 scripts into equivalent DataSonnet .ds files, enabling
easier migration of Mule integrations to Apache Camel.

The transpiler includes:
- Hand-written recursive descent parser for DataWeave 2.0 syntax
- AST-based conversion to DataSonnet with Camel CML functions
- Support for field access, operators, type coercion, null handling,
  collection operations (map/filter/reduce/flatMap/groupBy/orderBy),
  string operations, if/else, var/fun declarations
- Unsupported constructs flagged with TODO comments
- 43 unit tests covering all conversion patterns

CLI usage:
  camel transform dataweave --input flow.dwl --output flow.ds
  camel transform dataweave --input src/mule/ --output src/resources/
  camel transform dataweave -e 'payload.name default "unknown"'

Depends on PR #22156 (camel-datasonnet CML enhancements).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions github-actions bot added the dsl label Mar 20, 2026
gnodet and others added 2 commits March 21, 2026 00:43
- Fix emitLambda: String.join was missing paramNames argument
- Fix emitStringLit: remove double-escaping of backslashes
- Fix startsWith/endsWith: use c.startsWith/c.endsWith from camel.libsonnet
  (DataSonnet std doesn't have these)
- Fix orderBy: use c.sortBy from camel.libsonnet instead of std.sort
- Fix min/max: use c.min/c.max from camel.libsonnet
- Flag abs/round/sqrt as TODO (not available in DataSonnet std)
- Remove unused KEYWORDS set from lexer
- Add tests for startsWith, endsWith, escape preservation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add *.dwl to the license-maven-plugin excludes list since the plugin
does not have a comment style definition for DataWeave files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

ℹ️ CI did not run targeted module tests (all projects built or tests skipped).

@gnodet gnodet marked this pull request as ready for review March 21, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants