-
Notifications
You must be signed in to change notification settings - Fork 3.2k
add new field updatedRows to QueryStatistics.java where it's availabl… #24810
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
base: master
Are you sure you want to change the base?
add new field updatedRows to QueryStatistics.java where it's availabl… #24810
Conversation
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 |
Hi @chenjian2664 @wendigo |
336a5e4
to
01467dd
Compare
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a test for it?
Please rephrase commit https://github.com/trinodb/trino/blob/master/.github/DEVELOPMENT.md
That's actually my next question. |
01467dd
to
9fe872e
Compare
9fe872e
to
2555e53
Compare
5755355
to
de4be2d
Compare
Hi @chenjian2664 @wendigo |
de4be2d
to
1948ead
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @Praveen2112
For the EventListener, I think you may have some thoughts
plugin/trino-hive/src/test/java/io/trino/plugin/hive/orc/TestHiveOrcWithShortZoneId.java
Outdated
Show resolved
Hide resolved
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
@ThreadSafe | ||
public class EventsCollector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There already exists a EventsCollector, why not reuse it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I explained it in the previous commit message:
The test (for UPDATE/DELETE queries) was added to BaseConnectorTest.java and it needs the classes like EventsAwaitingQueries and QueryEvents that exist in trino-tests module. So, I moved the needed classes from trino-tests to trino-testing where they are exposed to both trino-tests and trino-testing.
I removed those classes from trino-tests
and added to trino-testing
so both the old and the new tests can have access to them.
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
|
||
@ThreadSafe | ||
public class QueryEvents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, why not reuse it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to the last review.
@@ -332,6 +332,7 @@ private static QueryStats immediateFailureQueryStats() | |||
DataSize.ofBytes(0), | |||
0, | |||
0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the commits head wrap to 50 characters, body to 72 characters https://github.com/trinodb/trino/blob/master/.github/DEVELOPMENT.md.
1948ead
to
19f5709
Compare
23f1604
to
aa5f1fa
Compare
1e2a07c
to
4ddc159
Compare
Hi @Praveen2112 @chenjian2664 @wendigo |
4ddc159
to
3b77122
Compare
baa4f5e
to
37ed58a
Compare
fe310d5
to
6051153
Compare
a6509ed
to
193b4aa
Compare
4cefaad
to
2e1e751
Compare
Come from TableMutationOperator and MergeWriteOperator's rowCount
2e1e751
to
eb69b6f
Compare
…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.javaDescription
The issue that this pull request tries to fix is that after running UPDATE/DELETE queries, the
outputRows
inQueryStatistics.java
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