add new field updatedRows
to QueryStatistics.java
#24808
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The issue that this pull request tries to fix is that after running UPDATE/DELETE queries, the
outputRows
inQueryStatistics
is always 1. But we need the actual value of updated rows. We figured out that the number of updated rows is returned inTableMutationOperator.java
methodgetOutput()
and also inMergeWriterOperator.java
the same method. The updated rows number is passed tooperatorContext
instance and from there, all the way down to theQueryStatistics.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:
#24596