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 validation for invalid partitioned by granularities #12589

Merged

Conversation

LakshSingla
Copy link
Contributor

@LakshSingla LakshSingla commented Jun 1, 2022

Description

This PR is in continuation to #12580 and rejects the ingest queries with PARTITIONED BY granularities that are not supported. For example queries withPARTITIONED BY clause set to TIME_FLOOR(__time, 'PT2H') are rejected in the validation layer itself. Unit tests for the same have been added.

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.

if(!GranularityType.isStandard(granularity))
{
throw new IAE("The granularity specified in PARTITIONED BY is not supported. "
+ "Please use a standard granularity.");
Copy link
Contributor

Choose a reason for hiding this comment

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

What does standard granularity mean? How does the user know that these are the granularities I can use. _

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, does simple granularities seem more appropriate? https://druid.apache.org/docs/latest/querying/granularities.html

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO I would map GranularityType.values() to period and then use a string Joiner with "," and put that in the exception message.

@@ -55,7 +55,9 @@ data: {
"org.apache.calcite.sql.SqlNode"
"org.apache.calcite.sql.SqlInsert"
"org.apache.druid.java.util.common.granularity.Granularity"
"org.apache.druid.java.util.common.granularity.GranularityType"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: do you still need granularity type here.

Copy link
Contributor

@cryptoe cryptoe left a comment

Choose a reason for hiding this comment

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

LGTM !!

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.

5 participants