Skip to content

fix(outputs.sql): Add timestamp to derived datatypes #17310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2025

Conversation

Soldrym
Copy link
Contributor

@Soldrym Soldrym commented Jul 9, 2025

Summary

outputs.sql derived datatypes does not account for time.Time values causing errors.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #17309

@telegraf-tiger telegraf-tiger bot added area/sql fix pr to fix corresponding bug plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Jul 9, 2025
Copy link
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 @Soldrym! The code looks good. Could you please add a unit-test to avoid future regressions!?

@srebhan srebhan self-assigned this Jul 10, 2025
@Soldrym
Copy link
Contributor Author

Soldrym commented Jul 11, 2025

I added a unit test. Ran into issues where adding the field would just send through a nil and had to add a time.Time conversion to metric.convertField.

That was the most time I've ever spent adding 9 lines of code.

@Soldrym
Copy link
Contributor Author

Soldrym commented Jul 11, 2025

So I don't know what to do about this failing check.

It's in plugins/inputs/ecs. They unmarshal the a json source file into a struct called ecsTask with a slice of ecsContainer structs in it. The ecsContainer struct has the CreatedAt and StartedAt fields, so that all makes sense. The final output function (metastats) creates a map with keys created_at and started_at with the values of CreatedAt and StartedAt, but the expected data does not have those fields.

Before changing the metric convert field function, the ecs metastats function didn't output the created_at and started_at keys, so the expected matched the output. I just don't know if that's actually supposed to be like that. It looks like a bug in the ecs test but I don't know much about ECS.

Copy link
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.

@Soldrym your change to metric/metric.go will break many non-input plugins! Please revert this change, it's definitively not the right thing to do...

@telegraf-tiger
Copy link
Contributor

Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip.
Downloads for additional architectures and packages are available below.

👍 This pull request doesn't change the Telegraf binary size

📦 Click here to get additional PR build artifacts

Artifact URLs

. DEB . RPM . TAR . GZ . ZIP
[[amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip] [arm64.deb armel.rpm darwin_arm64.tar.gz windows_arm64.zip] [armel.deb armv6hl.rpm freebsd_amd64.tar.gz windows_i386.zip] [armhf.deb i386.rpm freebsd_armv7.tar.gz ] [i386.deb ppc64le.rpm freebsd_i386.tar.gz ] [mips.deb riscv64.rpm linux_amd64.tar.gz ] [mipsel.deb s390x.rpm linux_arm64.tar.gz ] [ppc64el.deb x86_64.rpm linux_armel.tar.gz ] [riscv64.deb linux_armhf.tar.gz ] [s390x.deb linux_i386.tar.gz ] [ linux_mips.tar.gz ] [ linux_mipsel.tar.gz ] [ linux_ppc64le.tar.gz ] [ linux_riscv64.tar.gz ] [ linux_s390x.tar.gz ]]

Copy link
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.

Awesome! Thanks a lot @Soldrym!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jul 17, 2025
@srebhan srebhan assigned skartikey and mstrandboge and unassigned srebhan Jul 17, 2025
Copy link
Contributor

@skartikey skartikey left a comment

Choose a reason for hiding this comment

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

@Soldrym Thanks!

@skartikey skartikey merged commit 467ac0c into influxdata:master Jul 18, 2025
27 checks passed
@github-actions github-actions bot added this to the v1.35.3 milestone Jul 18, 2025
skartikey pushed a commit that referenced this pull request Jul 28, 2025
Co-authored-by: Soldrym <soldrym@users.noreply.github.com>
(cherry picked from commit 467ac0c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sql fix pr to fix corresponding bug plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

outputs.sql - Unknown datatype time.Time with table updates enabled.
4 participants