Skip to content

字段运算后聚合结果为0 #791

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

Open
Jiuyong opened this issue Nov 9, 2018 · 8 comments
Open

字段运算后聚合结果为0 #791

Jiuyong opened this issue Nov 9, 2018 · 8 comments

Comments

@Jiuyong
Copy link

Jiuyong commented Nov 9, 2018

比如:
SELECT SUM(Rcvd + Sent) AS CNT FROM fire
生成的脚本为:
{ "from": 0, "size": 0, "_source": { "includes": [ "SUM" ], "excludes": [] }, "aggregations": { "CNT": { "sum": { "script": { "source": " def add_1765017519 = doc['Rcvd'].value + doc['Sent'].value", "lang": "painless" } } } } }
查询结果为 0 ,生成的脚本是否缺少 return add_1765017519;?
因为有结果的脚本:
SELECT (Rcvd + Sent) AS CNT FROM fire
生成的脚本为:
{ "from": 0, "size": 200, "_source": { "includes": [], "excludes": [] }, "script_fields": { "CNT": { "script": { "source": " def add_119484767 = doc['Rcvd'].value + doc['Sent'].value;return add_119484767;", "lang": "painless" }, "ignore_failure": false } } }

@shi-yuan
Copy link
Member

确实是个bug

@ibc789
Copy link

ibc789 commented Nov 13, 2018

这个bug还修改了?

@shi-yuan
Copy link
Member

会改的

@shi-yuan
Copy link
Member

shi-yuan commented Dec 3, 2018

{
  "from": 0,
  "size": 0,
  "_source": {
    "includes": [
      "SUM"
    ],
    "excludes": []
  },
  "aggregations": {
    "CNT": {
      "sum": {
        "script": {
          "source": " def add_1621566800 = doc['Rcvd'].value + doc['Sent'].value;return add_1621566800;",
          "lang": "painless"
        }
      }
    }
  }
}

@Jiuyong
Copy link
Author

Jiuyong commented Dec 4, 2018

你是说现在改好了吗?
这个我们临时修复的时候,导致了更高级的错误,因此没敢提PR。

@shi-yuan
Copy link
Member

shi-yuan commented Dec 4, 2018

上面有变更代码,可以看看哈

Jiuyong pushed a commit to Jiuyong/elasticsearch-sql that referenced this issue Dec 4, 2018
@Jiuyong
Copy link
Author

Jiuyong commented Dec 4, 2018

嗯,看了,不过在这里提交之后,我们发现了更深层次的衍生bug,所以这个issuse暂时别关,等我将同一个问题造成的关联bug都测试一下再回报给你。

@shi-yuan shi-yuan reopened this Dec 4, 2018
@shi-yuan
Copy link
Member

shi-yuan commented Dec 4, 2018

好的,先开着吧

yongkyun added a commit to yongkyun/elasticsearch-sql that referenced this issue May 28, 2019
* one result returned on es5.0
there is just on result on dataset ..  @allwefantasy why you made this test with 2?

* split is not working on painless (worked on groovy) . waiting for a workaround .
elastic/elasticsearch#20952

* no java7 support (travis)
no delete-by-query plugin to copy

* check java version. getting bad minor version error

* java version of sudo was 1.7 , trying to start elastic service without sudo

* can't run elasticsearch service without sudo. trying to install java8 with sudo.

* put java8 install at first

* still getting java7 on sudo , trying different approach

* getting java8 to sudo different approach

* travis - try and make sure elasticsearch is up

* new config for es5.0 yml

* add finalName elasticsearch so base folder should be elasticsearch (demand for plugins es5.0)

* fix plugin and make csv rest to work

* fix to plugin-description properties

* fix all math functions

* update README.md

* add delete tests again

* site with node server

* elasticsearch 5.0.1 release

* es 5.1.1 support
script api changed

* travis - download es 5.1.1

* 5.1.1 support

* regex support

* add auth for NLPchina#364

* update README.md

* NLPchina#364 support base_uri,usename,password url parameters

* localStorage set item auth

* es 5.1.2 support

* update README.md

* README: Fix build status heading [ci skip]

* README: Fix markdown

* es 5.2.0 support for NLPchina#402

* update README.md

* es 5.2.1 support

* update README.md

* es 5.2.2 support

* update README.md

* es 5.3.0 support for NLPchina#405

* update .travis.yml

* update README.md

* es 5.3.1 support for NLPchina#416

* update README.md

* es 5.3.2 support

* update README.md

* update README.md

* Fix Beyond SQL Heading Format

* fix bug
当查询条件里面是double 数字是,druid 默认解析完的是BigDecimal 类型的,导致 es StreamOut writer 报错

* es 5.4.0 support

* fix test issue

* update README.md

* Fix header

* es 5.4.1 support

* update README.md

* update README.md

* NLPchina#439 add property ‘min_doc_count’

* NLPchina#457 es 5.4.2 support

* update README.md

* es 5.4.3 support

* es 5.5.0 support

* update README.md

* fix bug NLPchina#469

* update README.md

* fix bug NLPchina#480

* 让ElasticSearchResultSetMetaDataBase可以获取到列的metadata信息

* NLPchina#485 es 5.5.1 support

* update README.md

* Fixbug NLPchina#479

* 修复聚合函数对查询字段不包含在include单元测试不通过问题

* fix bug NLPchina#494

* NLPchina#503 es 5.5.2 support

* update README.md

* new feature: cast, almost same sa SQL cast, cast field type to int/long/float/double/string/datetime

* fix issue NLPchina#510

* es 5.5.3 support

* es 5.6.0 support

* es 5.6.1 support

* es 5.6.2 support

* update README.md

* fix junit test

* update

* update

* update

* fix issue NLPchina#515

* Correct syntax 'sql' to 'SQL'

* NLPchina#529 es 5.6.3 support

* update README.md

* fix issue 聚合字段为内嵌类型,聚合查询不正确NLPchina#527

* test

* add param order#536 How to change the order in date_histogram

* NLPchina#538 support extended_bounds in date_histogram

* fix issues 541

* NLPchina#540 fix NullPointerException

* Add support for Elasticsearch 5.6.4

Resolves: NLPchina#545

* Update README to include 5.6.4 changes

* Add missing newline to README

* fix issue 在match_phrase中设置slop NLPchina#550

* fix issue NLPchina#563 scripted_metric almost cannot be used

* es 5.6.5 support

* update README.md

* commit for 6.0.0 - compiling but not working, most tests are broken

* fix tests NLPchina#553

* update README.md

* update elasticsearch.yml

* es 6.0.1 support

* es 6.1.0 support

* es 6.1.1 support

* update README.md

* regex support

* fix delete by query NLPchina#347

* Support Field Collapsing

* support post_filter hint NLPchina#586

* fix nested order have bug NLPchina#438

* es 6.1.2 support

* Update controllers.js

just some wording

* Update README.md

* update README.md

* terms agg add execution_hint NLPchina#598

* fix Got error when filter with boolean field NLPchina#603

* fix CSV option giving -Infinity and Nan NLPchina#597

* es 6.1.3 support

* update README.md

* es 6.2.0 support

* es 6.2.1 support

* update README.md

* fix 6.2.1 Error on installation NLPchina#610

* upgrade version

* es 6.2.2 support

* update README.md

* fix issue RANGE COUNT PROBLEAM NLPchina#619

* fix issue [Feature request]Provide option to get query as locally on client, without connection to ES NLPchina#618

* fix nested类型字段不存在的情况下,用elasticsearch-sql无法查询到 NLPchina#628

* es 6.1.4 support

* es 6.2.3 support

* update README.md

* support multi_match query NLPchina#638

* NLPchina#640 date math support in index names

* support time zone in date format function

* NLPchina#531 add include and exclude

* NLPchina#648 es 6.2.4 support

* update README.md

* fix NLPchina#653 复杂运算查询会报错

* support scroll_id in sql NLPchina#575

* fix NLPchina#657 last(),IsLast()这类方法以后也不打算支持吗

* support connectionProperties for JDBC

* support multiple type of logs function

1) log2(param)
2) log10(param)
3) log(param) base=e
4) log(base_number, param)

* fix power function parameter error

change pow(a) to pow(a,b)

* fix NLPchina#638 bug

* fix NLPchina#678 range aggregation how to spec alias?

* es 6.3.0 support

* update README.md

* fix NLPchina#686

* support date_histogram,histogram and terms aggregations with scripts

* es 6.3.1 support

* update README.md

* fix NLPchina#714 SQL parse error when where condition contains 'join' keyword

* Update README.md

* es 6.3.2 support

* update README.md

* NLPchina#736 fix testcase selectFieldWithSpace

* fix NLPchina#742

* fix 使用jdbc调用metaData.getColumnCount()函数无法获取正常列数信息的问题 NLPchina#751

* fix bug#connection in druid infinitely increased

* es 6.4.0 support

* update README.md

* fix NLPchina#734

* es 6.4.1 support

* update README.md

* fix NLPchina#688 How to use the feature 'inner_hits' when filed is the array of nested object

* es 6.4.2 support

* update README.md

* fix NLPchina#781 中文查询无结果

* fix bug in floor(cast(var as int)  and sum(cast(var as int))

* fix NLPchina#779 How to use SpanNearQuery in SQL Plugin

* update testcase testSpanNearQueryExplain

* fix NLPchina#791 字段运算后聚合结果为0

* es 6.4.3 support

* es 6.5.0 support

* fix NLPchina#800 nested parser

* fix NLPchina#807 时区问题

* update .travis.yml

* es 6.5.1 support

* update README.md

* update README.md

* fix NLPchina#821 date_histogram offset

* es 6.5.2 support

* update README.md

* fix NLPchina#826 es 6.5.3 support

* update README.md

* close resultset when closing preparedstatement

* update README.md

* Merge pull request NLPchina#793 from LongLonger/elastic6.1.1_zhongshu_dev_01

* es 6.5.4 support

* update README.md

* fix NLPchina#853

* fix NLPchina#847

* support json to extended_bounds config of dateHistogram

* check agg is an instance of termsagg before set size or shardsize

* count(distinct a) 排序问题

* add testcase for NLPchina#862

* fix NLPchina#838 sql返回结果按照字段顺序返回

* fix NLPchina#839 support stats-groups

* es 6.6.0 support

* fix NLPchina#877 Cast not used in the where condition

* update README.md

* Update README.md

* fix NLPchina#884 delete sql support CONFLICTS hint

* fix NLPchina#904 es 6.6.1 support

* es 6.6.2 support

* update README.md

* es 6.7.0 support

* update README.md

* update .travis.yml

* fix NLPchina#917 check search response

* es 6.7.1 support

* update README.md
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

No branches or pull requests

3 participants