Skip to content

Conversation

@Henry2SS
Copy link
Contributor

@Henry2SS Henry2SS commented Apr 8, 2022

Proposed changes

Issue Number: close #8918

Problem Summary:

Describe the overview of changes.

Checklist(Required)

  1. Does it affect the original behavior: (No)
  2. Has unit tests been added: (Yes)
  3. Has document been added or modified: (No Need)
  4. Does it need to update dependencies: (No)
  5. Are there any changes that cannot be rolled back: (No)

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

protected abstract String toSqlImpl();

protected String toDigestImpl() {
return toSqlImpl();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should throw NotImplementedException here?
So that we can ensure that every newly added Expr subclass will override this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx for your reply.
The abstract method toSqlImpl() will be overrided in each subclass. So there is no need to throw out exceptions.
The only situation is that a newly added subclass, which its sql digest needs to be different from sql impl, should override this method.

Added comments over this method to remind developers.

@github-actions github-actions bot added the area/planner Issues or PRs related to the query planner label Apr 11, 2022
@morningman morningman added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 13, 2022
@Override
public String toDigestImpl() {
StringBuilder sb = new StringBuilder();
sb.append(fnCall.toDigest()).append(" OVER (");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need those OVER or PARTITION BY keywords in digest?
maybe just a prefix like AnalyticExpr is enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I'm not quite sure about the performance impact of this implementation.
Looks like these are too much string operations.
Have you test its performance? Especially in high concurrency senario.

And I found some reference about how to implement digest or fingerprint of a SQL:
https://segmentfault.com/a/1190000040132966

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx.
I've tested locally, there is a 10% query performance loss. It looks bad.

So decide to put it in auditAfterExec() and only for slow queries.

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

Also need to update audit loader plugin:

fe_plugins/auditloader/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java
fe_plugins/auditloader/src/main/java/org/apache/doris/plugin/audit/DorisStreamLoader.java

@Henry2SS
Copy link
Contributor Author

Also need to update audit loader plugin:

fe_plugins/auditloader/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java
fe_plugins/auditloader/src/main/java/org/apache/doris/plugin/audit/DorisStreamLoader.java

Done.

@github-actions github-actions bot added the kind/docs Categorizes issue or PR as related to documentation. label Apr 21, 2022
@morrySnow
Copy link
Contributor

please fix conflicts ❤️

@Henry2SS
Copy link
Contributor Author

Henry2SS commented May 7, 2022

please fix conflicts ❤️

Done~

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman added the dev/backlog waiting to be merged in future dev branch label May 7, 2022
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label May 7, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

PR approved by anyone and no changes requested.

@morrySnow
Copy link
Contributor

please fix fe code style error, thanks

@morningman morningman merged commit c633402 into apache:master May 8, 2022
starocean999 pushed a commit to starocean999/incubator-doris that referenced this pull request May 19, 2022
englefly pushed a commit to englefly/incubator-doris that referenced this pull request May 23, 2022
@morningman morningman mentioned this pull request Nov 21, 2022
@2416210017
Copy link

@Henry2SS @morrySnow @morningman Does Doris 2.1.5 have a configuration parameter to enable the recording of all SQL sql-digests in the audit log?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/planner Issues or PRs related to the query planner dev/backlog waiting to be merged in future dev branch kind/docs Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] sql digest is badly needed in many scenarios

4 participants