-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Description
Relevant telegraf.conf
[[outputs.sql]]
driver = "clickhouse"
data_source_name = "clickhouse://..."
table_update_template = "ALTER TABLE {TABLE} ADD COLUMN {COLUMN}"
[outputs.sql.convert]
conversion_style = "literal"
integer = "Int64"
text = "String"
timestamp = "DateTime"System info
Telegraf version: master branch
Database: ClickHouse (also affects other databases)
Steps to reproduce
- Configure SQL output plugin with
table_update_templateset - Ensure tables already exist in the database with columns
- Start Telegraf and write metrics to existing tables
- Observe error: "column already exists" when plugin tries to add existing columns
Expected behavior
Plugin should detect existing columns and only add new columns that don't exist.
Actual behavior
Plugin attempts to add ALL columns (including existing ones) to the table, causing errors like:
creating column failed: code: 15, message: Cannot add column \`timestamp\`: column with this name already exists
Additional info
The issue occurs because when `tableExists()` discovers an existing table, it creates an empty column cache but never populates it with actual columns from the database. This causes `createColumn()` to think no columns exist and attempts to add them all.
Metadata
Metadata
Assignees
Labels
No labels