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

connector: support sinking jsonb as dynamic type #11699

Closed
xiangjinwu opened this issue Aug 15, 2023 · 3 comments · Fixed by #17693
Closed

connector: support sinking jsonb as dynamic type #11699

xiangjinwu opened this issue Aug 15, 2023 · 3 comments · Fixed by #17693
Assignees
Milestone

Comments

@xiangjinwu
Copy link
Contributor

xiangjinwu commented Aug 15, 2023

Is your feature request related to a problem? Please describe.

As an analogy to #10772, there are 2 styles to sink a jsonb value out:

Always as a JSON-encoded string:

  • 1 -> "1"
  • true -> "true"
  • null -> "null"
  • "foo" -> "\"foo\""
  • [1, true, "foo"] -> "[1, true, \"foo\"]"
  • {"k": 2} -> "{\"k\": 2}"

As different types based on jsonb_typeof:

  • 1 -> 1
  • true -> true
  • null -> null
  • "foo" -> "foo"
  • [1, true, "foo"] -> [1, true, "foo"]
  • {"k": 2} -> {"k": 2}

Currently the kafka sink uses the former style, because each RisingWave data type always maps to a single data type in output. But the latter form may be preferred in certain cases.

The latter style should report an error when the sink column is not dynamic type.

Describe the solution you'd like

Introduce a new sink option to switch between the 2 styles, similar to existing TimestampHandlingMode. The default can be used to retain backward compatibility.

Describe alternatives you've considered

No response

Additional context

(DataType::Jsonb, ScalarRefImpl::Jsonb(jsonb_ref)) => {
json!(jsonb_ref.to_string())
}

cc @StrikeW @tabVersion @BugenZhao

@maingoh

This comment was marked as off-topic.

@yuhao-su
Copy link
Contributor

Do we need this for DebeziumJson?

@xiangjinwu
Copy link
Contributor Author

Do we need this for DebeziumJson?

According to Debezium the jsonb data type is always mapped to Kafka Connect string type. It is never a dynamic type

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

Successfully merging a pull request may close this issue.

4 participants