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

add a sql option to force user to specify time condition #6246

Merged
merged 3 commits into from Sep 17, 2018

Conversation

gaodayue
Copy link
Contributor

@gaodayue gaodayue commented Aug 27, 2018

One downside of SQL's flexibility is that users tend to forget adding time filter when writing queries, which is usually very bad for timeseries data analysis and causes stability issue.

Since native query requires users to specify "intervals", I think it's reasonable to force SQL users to specify __time filter in many cases.

This PR adds a new option druid.sql.planner.requireTimeCondition to support such needs. It defaults to false though so that the default behaviour is the same as before.

@fjy
Copy link
Contributor

fjy commented Aug 27, 2018

I quite like this feature

@gaodayue
Copy link
Contributor Author

Hi @gianm , could you take a look at this?

@jon-wei
Copy link
Contributor

jon-wei commented Sep 14, 2018

@QiuMM Can you fix conflicts?

@gaodayue
Copy link
Contributor Author

conflict resolved. @jon-wei could you help review?

@jon-wei
Copy link
Contributor

jon-wei commented Sep 14, 2018

@QiuMM ah, whoops, I was reviewing both of your PRs and got mixed up

@gaodayue sure, I'm reviewing

@@ -57,6 +57,9 @@
@JsonProperty
private boolean useFallback = false;

@JsonProperty
private boolean forceTimeCondition = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest "requireTimeCondition" as the name instead.

"force" to me sounds like requiring the server to plan queries in a certain way, while this is more of a requirement on queries submitted by the user.

final Query innerMostQuery = findInnerMostQuery(query);
if (plannerContext.getPlannerConfig().isForceTimeCondition() &&
innerMostQuery.getIntervals().equals(Intervals.ONLY_ETERNITY)) {
throw new CannotBuildQueryException("Missing __time filter");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest having this error message mention the time condition property, so that users who encounter it know that the problem is with their query and not an internal server error.

e.g. "requireTimeCondition is enabled, all queries must include a filter condition on the __time column."

@gaodayue
Copy link
Contributor Author

@jon-wei thanks for your review, all comments have been addressed.

@jon-wei jon-wei merged commit edf0c13 into apache:master Sep 17, 2018
@dclim dclim added this to the 0.13.0 milestone Oct 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants