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

SQL: [Docs] Add example for custom bucketing with CASE #41787

Merged
merged 3 commits into from
May 6, 2019

Conversation

matriv
Copy link
Contributor

@matriv matriv commented May 3, 2019

Add a TIP on how to use CASE to achieve custom bucketing
with GROUP BY.

Follows: #41349

Add a TIP on how to use CASE to achieve custom bucketing
with GROUP BY.

Follows: elastic#41349
@matriv matriv added >docs General docs changes :Analytics/SQL SQL querying v8.0.0 v7.2.0 v7.1.0 labels May 3, 2019
@matriv matriv requested review from costin and astefan May 3, 2019 10:08
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM. Left few minor cosmetic comments.

===============================
CASE can be used as a GROUP BY key in a query to facilitate custom bucketing
and assign descriptive names to those buckets. If for example the number of
values for a key are too many or, simply, ranges of those values are more
Copy link
Contributor

Choose a reason for hiding this comment

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

the number ..... is too large. values.... are too many

[TIP]
===============================
CASE can be used as a GROUP BY key in a query to facilitate custom bucketing
and assign descriptive names to those buckets. If for example the number of
Copy link
Contributor

Choose a reason for hiding this comment

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

If, for example, the number....

GROUP BY lang_skills
ORDER BY lang_skills;

With this query, we can create normal grouping buckets for values _0, 1, 2, 3_ with
Copy link
Contributor

Choose a reason for hiding this comment

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

With this query, one can create

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

Left a comment - this is cool enough that it deserves its own section.

@@ -98,6 +98,31 @@ an error message would be returned, mentioning that *'foo'* is of data type *key
which does not match the expected data type *integer* (based on result *10*).
===============================

[[sql-functions-conditional-case-groupby-custom-buckets]]
[TIP]
Copy link
Member

Choose a reason for hiding this comment

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

I would remove the TIP header and promote this to a section (=====) - I think it's big enough to warrant a proper entry.

@matriv matriv merged commit eb5f5d4 into elastic:master May 6, 2019
@matriv matriv deleted the groupby-docs-case branch May 6, 2019 15:01
matriv added a commit that referenced this pull request May 6, 2019
Add a TIP on how to use CASE to achieve custom bucketing
with GROUP BY.

Follows: #41349

(cherry picked from commit eb5f5d4)
@matriv matriv removed the v7.1.0 label May 6, 2019
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request May 7, 2019
* elastic/master: (414 commits)
  Add tasks to build Docker build context artifacts (elastic#41819)
  Replace more uses of immutable map builder (elastic#41823)
  Force selection of calendar or fixed intervals in date histo agg (elastic#33727)
  Switch run task to use real distro (elastic#41590)
  Clarify that path_match also considers object fields. (elastic#41658)
  [DOCS] remove 'es.scripting.update.ctx_in_params' system property for 7.0 (elastic#41643)
  Clarify _doc is a permanent part of certain document APIs. (elastic#41727)
  Remove the jdk directory to save space on bwc tests (elastic#41743)
  Fix full text queries test that start with now (elastic#41854)
  Remove `nonApplicationWrite` from `SSLDriver` (elastic#41829)
  SQL: [Docs] Add example for custom bucketing with CASE (elastic#41787)
  Cleanup Bulk Delete Exception Logging (elastic#41693)
  [DOCS] Rewrite `term` query docs for new format (elastic#41498)
  Mute PermissionsIT#testWhen[...]ByILMPolicy (elastic#41858)
  ReadOnlyEngine assertion fix (elastic#41842)
  [ML] addresses preview bug, and adds check to PUT (elastic#41803)
  Fix javadoc in WrapperQueryBuilder
  Testsclusters use seprate configurations per version (elastic#41504)
  Skip explain fetch sub phase when request holds only suggestions (elastic#41739)
  remove unused import
  ...
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
* SQL: [Docs] Add example for custom bucketing with CASE

Add a TIP on how to use CASE to achieve custom bucketing
with GROUP BY.

Follows: elastic#41349

* address comments

* address comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/SQL SQL querying >docs General docs changes v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants