Skip to content

Add convert.parse object parsing wrangle - #1187

Open
ebhills wants to merge 1 commit into
mainfrom
align-convert-to-froms
Open

ebhills wants to merge 1 commit into
mainfrom
align-convert-to-froms

Conversation

@ebhills

@ebhills ebhills commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator
  • Introduce a new convert.parse recipe wrangle that parses JSON, Python literals, and YAML-like object text into JSON-compatible Python values. The implementation adds expected-type validation, per-column defaults, missing-value handling, normalization for numpy-backed objects, and safer YAML scalar resolution.

  • Eventually could replace from_yaml, from_json

  • Tests cover valid inputs, quoted structures, defaults, type mismatches, invalid values, and multi-column behavior.

Linked issue

Closes #

What changes

Describe the user-visible or API behavior change. Keep unrelated changes in a
separate PR.

How it was verified

List the focused tests and any manual or live-service verification performed.

Compatibility and risk

Describe compatibility impact, migration needs, credentials/external services,
and the safest rollback.

Ready-for-review checklist

  • One human delivery owner is assigned
  • The linked issue and intended milestone are correct
  • The branch is current with main and has no merge conflicts
  • Focused tests pass
  • New or changed behavior has direct test coverage
  • Documentation/schema/configuration is updated where applicable
  • The PR contains no unrelated changes
  • The PR description reflects the branch's current scope and latest validation
  • One primary reviewer is requested only when this PR is ready

See the pull request workflow.

 - Introduce a new `convert.parse` recipe wrangle that parses JSON, Python literals, and YAML-like object text into JSON-compatible Python values. The implementation adds expected-type validation, per-column defaults, missing-value handling, normalization for numpy-backed objects, and safer YAML scalar resolution.

 - Eventually could replace from_yaml, from_json

-  Tests cover valid inputs, quoted structures, defaults, type mismatches, invalid values, and multi-column behavior.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Default normalization, schema validation, and YAML alias resource-safety issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds convert.parse for converting JSON, Python literals, and YAML-like text into JSON-compatible Python values.

Changes:

  • Adds parsing, normalization, expected-type validation, and fallback handling.
  • Adds comprehensive recipe-level tests for supported inputs and edge cases.
File summaries
File Description
wrangles/recipe_wrangles/convert.py Implements convert.parse and its schema.
tests/recipes/wrangles/test_convert.py Tests parsing, defaults, validation, and multiple columns.
Review details

Suppressed comments (1)

wrangles/recipe_wrangles/convert.py:645

  • The invalid/type-mismatch fallback also skips _normalize_json_compatible, so NumPy-backed or otherwise unsupported defaults can escape unchanged. Apply the same normalization as successful parsed values so every return path honors the JSON-compatible result contract.
                    return _copy.deepcopy(col_default)
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

pass

try:
return _yaml.load(value, Loader=_ObjectYAMLLoader)
Comment on lines +579 to +592
type:
- string
- array
description: >-
Required result category. Use any, dictionary, list, or scalar.
A list may provide one category per input column.
default: any
items:
type: string
enum:
- any
- dictionary
- list
- scalar
if _is_missing_object_value(value):
if col_default is _DEFAULT_NOT_SET:
return None
return _copy.deepcopy(col_default)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants