Add uint64 (and uint32?) type conversion methods to bloblang
After upgrading from v1 to v2 of library go-clickhouse ins't possible to write numbers (benthos) with UInt type in clickhouse and string to Date/Datetime type
For example: I create table experiment
CREATE TABLE default.experiment
(
`count` UInt64
)
ENGINE = MergeTree
ORDER BY tuple()
SETTINGS index_granularity = 819
┏━━━━━━━| ┃ name | type | ┡━━━━━━━| │ count │ UInt64 │ └───────|
And have this config:
input:
generate:
interval: 10s
mapping: 'root = {"count": 20}'
pipeline:
threads: 1
processors:
- log:
message: ${!this}
output:
sql_insert:
driver: clickhouse
dsn: clickhouse://127.0.0.1:9000?database=default
table: "experiment"
columns: [
count
]
args_mapping: |
root = [
this.count
]
logger:
level: ALL
format: json
add_timestamp: true
static_fields:
'@service': service
I got this error:
{"@service":"service","label":"","level":"error","msg":"Failed to send message to sql_insert: clickhouse [AppendRow]: count clickhouse [AppendRow]: converting int64 to UInt64 is unsupported","path":"root.output","time":"2022-09-01T13:02:07+03:00"}
In v1 version many of types conversion was under the hood of library, but in v2 they are don't do implicit conversion of types due to performance – https://github.com/ClickHouse/clickhouse-go/blob/examples/TYPES.md
Another problem with date/datetime types. In first version of go-clickhouse i used 'strings' for that ('2022-01-01') in benthos, but in v2 it's not possible.
Are there workarounds in benthos for this issues.
Hey @packman80, the timestamp methods (https://www.benthos.dev/docs/guides/bloblang/methods#ts_parse, etc) now return explicit timestamp values. Looks like we'd need to add an explicit method for creating a uint value.
Hi, I just incur in a similar issue with this error:
Failed to send message to sql_insert: clickhouse [AppendRow]: sport clickhouse [AppendRow]: converting int64 to Int32 is unsupported Failed to send message to sql_insert: clickhouse [AppendRow]: packets clickhouse [AppendRow]: converting json.Number to Int64 is unsupported
Can be possible to have type conversion functions in bloblang?
Fixed with https://github.com/benthosdev/benthos/commit/2225bf849ba2637c3dba91708036e968b6bea99d
@Jeffail Thank you!