Skip to content
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

Conversation

TSFenwick
Copy link
Contributor

@TSFenwick TSFenwick commented Jun 6, 2022

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:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Copy link
Contributor

@kfaraz kfaraz left a 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,

  1. default query context params can be set as runtime properties
  2. these are read by QueryLifecycle but not SqlLifecycle
  3. SQL execution still honors these default params as it is converted to a native query at which point a QueryLifecycle gets involved
  4. 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 in QueryLifecycle) does not affect behaviour

@TSFenwick
Copy link
Contributor Author

TSFenwick commented Jun 7, 2022

@kfaraz you understood it completely.

I'll see what I can do about implementing those two tests you want

@TSFenwick TSFenwick requested a review from kfaraz June 8, 2022 05:08
Copy link
Contributor

@kfaraz kfaraz left a 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);
}


Copy link
Contributor

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())));
Copy link
Contributor

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.

@kfaraz kfaraz merged commit a3603ad into apache:master Jun 8, 2022
@abhishekagarwal87 abhishekagarwal87 added this to the 24.0.0 milestone Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants