Fix NPE while loading lookups from empty JDBC source#16307
Fix NPE while loading lookups from empty JDBC source#16307kfaraz merged 3 commits intoapache:masterfrom
Conversation
cryptoe
left a comment
There was a problem hiding this comment.
Changes lgtm.
Thanks for your first pr in apache druid.
🚀
| .first() | ||
| ); | ||
| if (update == null) { | ||
| LOG.info("Lookup table is empty. No rows returned for the query: %s", query); |
There was a problem hiding this comment.
Lets add the look up name here.
There was a problem hiding this comment.
@cryptoe The cache scheduler layer doesn't seem to have lookup name information. It only has the JdbcExtractionNamespace level information - which is what gets logged everywhere else in the cache scheduler layer as well.
Technically we can add an extra method param to send lookup name info all the way down to the cache layer through the whole method chain, but that seems unnecessary to me. That would also then require us to change logging everywhere else in the cache layer, just to ensure consistency - so it would end up as a much wider change.
Thoughts?
There was a problem hiding this comment.
You can do this:
| LOG.info("Lookup table is empty. No rows returned for the query: %s", query); | |
| LOG.info("Lookup table[%s] is empty. No rows returned for the query[%s].", table, query); |
There was a problem hiding this comment.
Wouldn't INFO logging be too noisy, given that this will log every time we run a check (to see whether to update the table or not)? (By default, it is set to not poll, so the default behaviour is cool)
There was a problem hiding this comment.
@LakshSingla This is going to be logged only if the table is empty, so I think it should be fine.
|
Thanks for the fix, @Akshat-Jain ! |
Description
Currently, when we add a lookup with the lookupExtractorFactory's type as
cachedNamespaceconfigured with a JDBC source, we run into NPE while loading the lookup if the configured JDBC source table has no rows.Sample NPE logs:
This PR handles the NPE, and adds a test for validating the corresponding flow.
This PR has: