-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Make default query context show up in sql query logs #12613
Make default query context show up in sql query logs #12613
Conversation
…up in query logs also has a unit test
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.
Thanks for the changes, @TSFenwick !
If I understand the problem correctly,
- default query context params can be set as runtime properties
- these are read by
QueryLifecycle
but notSqlLifecycle
- SQL execution still honors these default params as it is converted to a native query at which point a
QueryLifecycle
gets involved - these default query params don't show up in logs or metrics emitted from the
SqlLifecycle
Please correct me if I have missed anything. If this is the current behaviour, then your changes look good.
I would be nice if you could also add tests (or confirm that these tests already exist) to:
- ensure that SQL queries do indeed honor the default query params
- double writing of the default query params (once in
SqlLifecycle
and once inQueryLifecycle
) does not affect behaviour
sql/src/main/java/org/apache/druid/sql/SqlLifecycleFactory.java
Outdated
Show resolved
Hide resolved
@kfaraz you understood it completely. I'll see what I can do about implementing those two tests you want |
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.
Minor nitpicks. Overall LGTM.
@@ -237,6 +242,8 @@ public void configure(Binder binder) | |||
clientLosAngeles = DriverManager.getConnection(url, propertiesLosAngeles); | |||
} | |||
|
|||
|
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.
Nit: extra newlines.
@@ -214,6 +218,7 @@ public void configure(Binder binder) | |||
.toProvider(QuerySchedulerProvider.class) | |||
.in(LazySingleton.class); | |||
binder.bind(QueryMakerFactory.class).to(NativeQueryMakerFactory.class); | |||
binder.bind(new TypeLiteral<Supplier<DefaultQueryConfig>>(){}).toInstance(Suppliers.ofInstance(new DefaultQueryConfig(ImmutableMap.of()))); |
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.
Nit: style
Maybe break up this line so that it's easier to read.
Fixes an issue where when you look at the sql query request logs emitted via an emitter or logged would be missing default query context values set in runtime.properties
Description
Added DefaultQueryConfig to SqlLifecycle ...
This was chosen because while the default query context is added as part of QueryLifecycle it was never added as part of the sql lifecycle meaning it wouldn't show up in the logs or when emitted via an emitter. Since this is a duplicate value with the values being added at QueryLifecycle there should no worries about the eventual double write of default query context values
Key changed/added classes in this PR
SqlLifecycle
This PR has: