Skip to content

feat(outputs.sql): Add oracle driver#19036

Open
sull1vxn wants to merge 5 commits into
influxdata:masterfrom
sull1vxn:oracle-sql
Open

feat(outputs.sql): Add oracle driver#19036
sull1vxn wants to merge 5 commits into
influxdata:masterfrom
sull1vxn:oracle-sql

Conversation

@sull1vxn
Copy link
Copy Markdown

@sull1vxn sull1vxn commented Jun 4, 2026

Summary

Adds Oracle support for outputs/sql plugin. Involved small additions to the code in outputs/sql/sql.go which encouraged slight stylistic changes (namely converting some if blocks to switches). Also added 3 integration tests for the Oracle support.

Checklist

Related issues

resolves #18959

@sull1vxn sull1vxn changed the title Oracle sql Feature Request: Oracle implementation to sql outputs plugin Jun 4, 2026
@sull1vxn sull1vxn changed the title Feature Request: Oracle implementation to sql outputs plugin feat: Oracle implementation to sql outputs plugin Jun 4, 2026
@telegraf-tiger telegraf-tiger Bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jun 4, 2026
Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @sull1vxn! Please find my comments below...

Comment thread plugins/outputs/sql/sql.go Outdated
Comment on lines 98 to 111
switch p.Driver {
case "sqlite":
p.tableListColumnsTemplate = "SELECT name AS column_name FROM pragma_table_info({TABLE})"
case "oracle":
p.tableListColumnsTemplate = "SELECT column_name FROM all_tab_columns WHERE table_name = {TABLE}"
case "mssql", "mysql", "pgx", "snowflake", "clickhouse":
p.tableListColumnsTemplate = "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME={TABLE}"
default:
return fmt.Errorf("unknown driver %q", p.Driver) // checks for valid driver
}

// Check for a valid driver
switch p.Driver {
case "clickhouse":
// Convert v1-style Clickhouse DSN to v2-style
if p.Driver == "clickhouse" {
p.convertClickHouseDsn()
case "mssql", "mysql", "pgx", "snowflake", "sqlite":
// Do nothing, those are valid
default:
return fmt.Errorf("unknown driver %q", p.Driver)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please merge this into

Suggested change
switch p.Driver {
case "sqlite":
p.tableListColumnsTemplate = "SELECT name AS column_name FROM pragma_table_info({TABLE})"
case "oracle":
p.tableListColumnsTemplate = "SELECT column_name FROM all_tab_columns WHERE table_name = {TABLE}"
case "mssql", "mysql", "pgx", "snowflake", "clickhouse":
p.tableListColumnsTemplate = "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME={TABLE}"
default:
return fmt.Errorf("unknown driver %q", p.Driver) // checks for valid driver
}
// Check for a valid driver
switch p.Driver {
case "clickhouse":
// Convert v1-style Clickhouse DSN to v2-style
if p.Driver == "clickhouse" {
p.convertClickHouseDsn()
case "mssql", "mysql", "pgx", "snowflake", "sqlite":
// Do nothing, those are valid
default:
return fmt.Errorf("unknown driver %q", p.Driver)
}
switch p.Driver {
case "sqlite":
p.tableListColumnsTemplate = "SELECT name AS column_name FROM pragma_table_info({TABLE})"
case "clickhouse":
p.tableListColumnsTemplate = "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME={TABLE}"
p.convertClickHouseDsn()
case "oracle":
p.tableListColumnsTemplate = "SELECT column_name FROM all_tab_columns WHERE table_name = {TABLE}"
case "mssql", "mysql", "pgx", "snowflake":
p.tableListColumnsTemplate = "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME={TABLE}"
default:
return fmt.Errorf("unknown driver %q", p.Driver) // checks for valid driver
}

Comment thread plugins/outputs/sql/sql.go Outdated

func (p *SQL) updateTableCache(tablename string) error {
stmt := strings.ReplaceAll(p.tableListColumnsTemplate, "{TABLE}", quoteStr(tablename))
fmt.Println(stmt)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's a left-over from debugging? Please remove!

Suggested change
fmt.Println(stmt)

Comment thread plugins/outputs/sql/sql_test.go Outdated
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
const username = "system"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please directly use the value at the respective locations instead of defining a constant here! Same for the other tests below!

@srebhan srebhan changed the title feat: Oracle implementation to sql outputs plugin feat(outputs.sql): Add oracle driver Jun 5, 2026
@telegraf-tiger telegraf-tiger Bot added area/sql plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Jun 5, 2026
@srebhan srebhan self-assigned this Jun 5, 2026
@telegraf-tiger
Copy link
Copy Markdown
Contributor

telegraf-tiger Bot commented Jun 6, 2026

@sull1vxn
Copy link
Copy Markdown
Author

sull1vxn commented Jun 6, 2026

@srebhan I have adjusted the code according to your comments

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

Labels

area/sql feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat Request: Oracle Driver support

2 participants