Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

aggregates over functions almost work #288

Closed
galkk opened this issue Nov 15, 2019 · 1 comment
Closed

aggregates over functions almost work #288

galkk opened this issue Nov 15, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@galkk
Copy link
Contributor

galkk commented Nov 15, 2019

Seems like the fix should be relatively simple, given that it generates aggregation correctly and only return in generated script is missing

POST /_opendistro/_sql/_explain
{
  "query":"""SELECT max(log(FlightDelayMin))
    FROM kibana_sample_data_flights
    GROUP BY DestCountry, dayOfWeek
  """
}
{
  "from" : 0,
  "size" : 0,
  "_source" : {
    "includes" : [
      "MAX"
    ],
    "excludes" : [ ]
  },
  "aggregations" : {
    "DestCountry" : {
      "terms" : {
        "field" : "DestCountry",
        "size" : 200,
        "min_doc_count" : 1,
        "shard_min_doc_count" : 0,
        "show_term_doc_count_error" : false,
        "order" : [
          {
            "_count" : "desc"
          },
          {
            "_key" : "asc"
          }
        ]
      },
      "aggregations" : {
        "dayOfWeek" : {
          "terms" : {
            "field" : "dayOfWeek",
            "size" : 10,
            "min_doc_count" : 1,
            "shard_min_doc_count" : 0,
            "show_term_doc_count_error" : false,
            "order" : [
              {
                "_count" : "desc"
              },
              {
                "_key" : "asc"
              }
            ]
          },
          "aggregations" : {
            "MAX(log_1=def log_1 = Math.log(doc('FlightDelayMin').value)/Math.log(Math.E))" : {
              "max" : {


MISSING RETURN HERE, THAT"S IT
                "script" : {
                  "source" : "def log_1 = Math.log(doc['FlightDelayMin'].value)/Math.log(Math.E)",
                  "lang" : "painless"
                }
              }
            }
          }
        }
      }
    }
  }
}
@dai-chen dai-chen added the enhancement New feature or request label Dec 30, 2019
@dai-chen
Copy link
Member

dai-chen commented Sep 9, 2020

The issue has been fixed in new query engine (which is experimental and disabled by default). You can enable it to preview by changing the plugin setting: https://github.com/opendistro-for-elasticsearch/sql/blob/master/docs/user/admin/settings.rst#opendistro-sql-engine-new-enabled. Thanks!

@dai-chen dai-chen closed this as completed Sep 9, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants