Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][io] The JDBC connector supports JSON substructure schema #23043

Merged
merged 1 commit into from
Jul 21, 2024

Conversation

shibd
Copy link
Member

@shibd shibd commented Jul 17, 2024

Motivation

Currently, when JDBC to convert value that has substructure schema, will get error:

java.lang.Exception: Not supported value type, need to add it. class org.apache.pulsar.client.impl.schema.generic.GenericJsonRecord

I know handling substructure types is complex, and JDBC databases may not always support defining substructure types.

However, it is possible to write the substructure type as a JSON string into the table. This can be very useful for databases that support JSON parsing.

For examples:

  1. JSON data
{
    "state": "ts",
    "zipCode": 1000,
    "pcList": [
        {
            "brand": "b1",
            "model": "m1"
        },
        {
            "brand": "b2",
            "model": "m2"
        }
    ]
}
  1. We can insert it to table like:
state zipCode pcList
ts 1000 [{"brand":"b1","model":"m1"},{"brand":"b2","model":"m2"}]

Modifications

  • When value instanceof GenericJsonRecord, use jsonNode string.

Verifying this change

  • Add testSubFieldJsonArray to cover it.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@shibd shibd self-assigned this Jul 17, 2024
@shibd shibd added this to the 3.4.0 milestone Jul 17, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jul 17, 2024
@shibd shibd added release/3.3.1 and removed doc-not-needed Your PR changes do not impact docs labels Jul 17, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jul 17, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 73.43%. Comparing base (bbc6224) to head (f860ca8).
Report is 453 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23043      +/-   ##
============================================
- Coverage     73.57%   73.43%   -0.15%     
- Complexity    32624    33101     +477     
============================================
  Files          1877     1914      +37     
  Lines        139502   143627    +4125     
  Branches      15299    15672     +373     
============================================
+ Hits         102638   105469    +2831     
- Misses        28908    30085    +1177     
- Partials       7956     8073     +117     
Flag Coverage Δ
inttests 27.61% <0.00%> (+3.02%) ⬆️
systests 24.66% <0.00%> (+0.34%) ⬆️
unittests 72.50% <50.00%> (-0.35%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
.../apache/pulsar/io/jdbc/BaseJdbcAutoSchemaSink.java 74.48% <50.00%> (+1.62%) ⬆️

... and 500 files with indirect coverage changes

@shibd shibd merged commit d08e2e0 into apache:master Jul 21, 2024
53 of 55 checks passed
shibd added a commit that referenced this pull request Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants