You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
What's the table look like? JSONStringEachRow seems incorrect here as I only saw JSONStringsEachRow at https://clickhouse.tech/docs/en/interfaces/formats/. If it's just a string, then you probably should use TabSeparated(make sure your JSON strings are all escaped).
Anyway, below is an example in SQL:
droptable aaa if exists;
createtableaaa(a String, b String, c UInt32) engine = Memory;
insert into aaa format JSONStringsEachRow
{"a":"1","b":"2","c":"3"}
{"a":"4","b":"5","c":"6"}
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.
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.
The text was updated successfully, but these errors were encountered: