Skip to content
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

add new field updatedRows to QueryStatistics.java #24808

Closed

Conversation

bhzaeri
Copy link

@bhzaeri bhzaeri commented Jan 27, 2025

Description

The issue that this pull request tries to fix is that after running UPDATE/DELETE queries, the outputRows in QueryStatistics is always 1. But we need the actual value of updated rows. We figured out that the number of updated rows is returned in TableMutationOperator.java method getOutput() and also in MergeWriterOperator.java the same method. The updated rows number is passed to operatorContext instance and from there, all the way down to the QueryStatistics.java which make the number available in the event listeners.
So far, we have tested this successfully on SQL Serevr, Hive, Mysql, and Postgresql.

Additional context and related issues

In our ransomware defender platform, we need to monitor the behavior of users who have access to run queries on the DBs connected via Trino. So, we need to be notified of users' actions and the exact results of their actions. Trino returns the correct values for SELECT and INSERT queries. We need the same for UPDATE/DELTE as well.

The only issue is that the current pull request doesn't include the proper unit tests for the changes. Could you please help us with the proper way to write the unit tests?

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`24596`)

#24596

bhzaeri and others added 5 commits January 27, 2025 15:02
…e in EventListener callbacks. It comes from TableMutationOperator.java where update/delete queries are issued.

add method `recordUpdatedPositions` to the OperatorContext class
update the updatedPositions for the queries run through MergeWriterOperator.java
This brings updated timezonedb to version 2024b
(openjdk/jdk23u@73b2341)
which amends historical timezone definitions for Mexico/Bahia_Banderas
that we use for testing timezone gap around the unix timestamp epoch.

Corresponding Joda time update also has these timezone definitions
updated. PostgreSQL test server was upgraded to 12 to correctly handle
UTC around epoch. MySQL was updated to 8.0.41 due to the same reason.

Temporary downgrade JDK for ppc64 to make CI happy
…e in EventListener callbacks. It comes from TableMutationOperator.java where update/delete queries are issued.

add method `recordUpdatedPositions` to the OperatorContext class
update the updatedPositions for the queries run through MergeWriterOperator.java
Copy link

cla-bot bot commented Jan 27, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@bhzaeri bhzaeri closed this Jan 27, 2025
@bhzaeri bhzaeri deleted the event-listener-updated-rows-number-3 branch January 27, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants