Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

parse json columns to python objects #177

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kingalban
Copy link

Problem

Currently the schema for json columns is object, but the actual value emitted is a string.

Proposed changes

The schema and the records need to match eachother. This change resolved this bug by making the record match the schema.

This is covered in issue 99. The open PR (101) to make the schema match the record. This isn't as favourable because it means json parsing must be done again on the target side.

I'm not very familiar with spatial datatypes in MySQL, so I can't say how this will affect them. I'm happy to write some tests if someone could point to an example of what they should look like.

Types of changes

When a column has object as one of it's type, it will be parsed from a json string to a python dict.
This may result in a JSONDecodeError if the json is malformatted.

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

  • Description above provides context of the change
  • I have added tests that prove my fix is effective or that my feature works
  • Unit tests for changes (not needed for documentation changes)
  • CI checks pass with my changes
  • Bumping version in setup.py is an individual PR and not mixed with feature or bugfix PRs
  • Commit message/PR title starts with [AP-NNNN] (if applicable. AP-NNNN = JIRA ID)
  • Branch name starts with AP-NNN (if applicable. AP-NNN = JIRA ID)
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions

@kingalban
Copy link
Author

As I mentioned, it is possible that this may cause the tap to fail with a JSONDecodeError if the database contains malformed json (I'm not famaliar enough to be sure MySQL enforces valid json).

If this is a serious concern, then I'd propose adding a config flag to enable this feature. If json parsing is disabled by that sort of option, then the tap would emit schemas which list json columns as string type

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant