Skip to content

[QUESTION] How to insert collection json strings into a table #681

Description

@cadet354

Hi, how to insert collection json strings into a table?
For example, I have a collection of objects, convert them to json strings and send them to a table.

// sorry for scala code
val sb = new StringBuilder()
events.map(ev => json.eventToString(ev)).foreach(s => sb.append(s +"\n"))
val stream = new ByteArrayInputStream(sb.toString().getBytes("UTF-8") )
try {
     sth.write().sendToTable(table, stream, ClickHouseFormat.JSONStringEachRow)
 } catch {
     case ex: java.sql.SQLException => log.error("An error occurred when inserting data into clickhouse", ex)
 }

but an exception occurs:
DB::Exception: Format JSONStringEachRow is not suitable for input (with processors).

I didn't find an example of using JSONStringEachRow in unit tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions