trino
trino copied to clipboard
add new field updatedRows to QueryStatistics.java where it's availabl…
…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
Description
The issue that this pull request tries to fix is that after running UPDATE/DELETE queries, the outputRows in QueryStatistics.java 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`)
https://github.com/trinodb/trino/issues/24596