Skip to content

feat(new source): Add ODBC source implementation - #24044

Open
powerumc wants to merge 193 commits into
vectordotdev:masterfrom
powerumc:powerumc/odbc-source
Open

feat(new source): Add ODBC source implementation#24044
powerumc wants to merge 193 commits into
vectordotdev:masterfrom
powerumc:powerumc/odbc-source

Conversation

@powerumc

@powerumc powerumc commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Summary

This PR implemented a new ODBC(Open Database Connectivity) Source.

Vector configuration

Manual configuration example

[sources.odbc]
type = "odbc"
connection_string = "driver={MySQL ODBC 8.0 ANSI Driver};server=localhost;port=13306;database=vector_db;uid=vector;pwd=vector;"
statement = "SELECT * FROM odbc_table WHERE id > ? LIMIT 1;"
schedule = "*/5 * * * * *"
schedule_timezone = "UTC"
last_run_metadata_path = "odbc_tracking.json"
tracking_columns = ["id"]
statement_init_params = { id = "0" }

[sinks.console]
type = "console"
inputs = ["odbc"]
encoding.codec = "json"

Create example sql file

cat << EOF > example.sql
DROP TABLE IF EXISTS odbc_table;
CREATE TABLE odbc_table
(
    id int auto_increment primary key,
    name varchar(255) null,
    datetime datetime null
);

INSERT INTO odbc_table (name, datetime) VALUES
('test1', now()),
('test2', now()),
('test3', now()),
('test4', now()),
('test5', now());
EOF

Configure ODBC and MariaDB Driver on MacOS

brew install unixodbc
brew install mariadb-connector-odbc

cat << EOF >> /opt/homebrew/etc/odbcinst.ini
[MariaDB Unicode]
Description=MariaDB Connector/ODBC v.3.0
Driver=/opt/homebrew/Cellar/mariadb-connector-odbc/3.2.7/lib/mariadb/libmaodbc.dylib
EOF

Run MariaDB docker container

docker run \
  --rm \
  --name mariadb \
  -e MYSQL_ROOT_PASSWORD=vector \
  -e MYSQL_USER=vector \
  -e MYSQL_PASSWORD=vector \
  -e MYSQL_DATABASE=vector_db \
  -v $(pwd)/example.sql:/docker-entrypoint-initdb.d/example.sql:ro \
  -p 3306:3306 \
  mariadb:latest

How did you test this PR?

I tested it with integration tests of two databases: MariaDB and Postgresql.
(Testing the MySQL container integration in an ARM64 architecture is not simple, so I tested it with MariaDB. Instead, I manually tested MySQL locally.)

cargo vdev integration test odbc-mariadb
cargo vdev integration test odbc-postgresql

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

powerumc added 29 commits July 24, 2025 20:53
# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	scripts/integration/Dockerfile
#	src/internal_events/mod.rs
#	src/sources/mod.rs
@github-actions github-actions Bot added the domain: sources Anything related to the Vector's sources label Oct 22, 2025
@pront pront assigned pront and unassigned thomasqueirozb Jul 31, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18692f7b78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/odbc/client.rs
Comment thread src/sources/odbc/client.rs
Comment thread src/internal_events/odbc_metrics.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3531b026f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/odbc/client.rs Outdated
Comment thread src/internal_events/odbc_metrics.rs
Comment thread src/sources/odbc/client.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a17af1b7bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/odbc/client.rs Outdated
Comment thread Cargo.toml

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e72d5bad5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/odbc/client.rs Outdated
Comment thread src/sources/odbc/client.rs
Comment thread website/cue/reference/components/sources/odbc.cue Outdated
Comment thread src/sources/odbc/config.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4348a79b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sources/odbc/client.rs
# Conflicts:
#	.github/workflows/test.yml
# Conflicts:
#	.github/workflows/test.yml
@powerumc
powerumc requested a review from pront August 11, 2026 23:27
# Conflicts:
#	Cargo.lock
#	LICENSE-3rdparty.csv

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55493e68ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +453 to +454
Ok(Err(error)) | Err(error) => {
return Err(error);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report buffered rows dropped by late query failures

When tracking_columns is enabled and the driver fails after returning one or more batches, such as on a mid-stream network or fetch error, those rows have already been counted by record_received and retained in pending_batches, but this return discards them without emitting ComponentEventsDropped. Fresh evidence beyond the earlier partial-batch accounting issue is that received metrics now run before tracking batches are buffered, so repeated failures can inflate received totals while the discarded event instances remain invisible; emit the buffered row count as dropped before returning the query error.

AGENTS.md reference: AGENTS.md:L218-L218

Useful? React with 👍 / 👎.

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

Labels

docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. domain: ci Anything related to Vector's CI environment domain: external docs Anything related to Vector's external, public documentation domain: releasing Anything related to releasing Vector domain: sources Anything related to the Vector's sources source: new Request or implementation of a new source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants