Skip to content

Use Decimal formatter for Numeric ValuesSourceTypes#54366

Merged
not-napoleon merged 6 commits intoelastic:masterfrom
not-napoleon:numeric-formatter-fix
Apr 20, 2020
Merged

Use Decimal formatter for Numeric ValuesSourceTypes#54366
not-napoleon merged 6 commits intoelastic:masterfrom
not-napoleon:numeric-formatter-fix

Conversation

@not-napoleon
Copy link
Copy Markdown
Member

I think this resolves #54365 and probably a few other places we were picking the wrong formatter.

@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

Copy link
Copy Markdown
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

That fixes both weighted_avg and t_test. We just need to make sure we don't pass time zone in SQL. Thanks!

@not-napoleon
Copy link
Copy Markdown
Member Author

@imotov What do you want to do with this? As you say, it's currently stuck on SQL's formatting behavior, which, honestly, I'm not sure how that was working before. The code I'm using here is taken directly from the field formatter, so I'm shocked it wasn't throwing from there before. Do you want to fix this SQL side and I'll pull the fix in here and see what we have?

Alternatively, I can change this to accept and ignore a timezone, which should get the tests passing. I don't love ignoring parameters, it seems excessively lenient, but it wouldn't be worse than it is now.

@imotov
Copy link
Copy Markdown
Contributor

imotov commented Mar 31, 2020

I have done some digging. Here is the reproduction of the issue that doesn't involve SQL:

DELETE test
PUT test
{
  "mappings": {
    "properties": {
      "start": {
        "type": "date"
      }
    }
  }
}

PUT test/_doc/1
{
  "start": "2020-01-01T00:00:00"
}

PUT test/_doc/2
{
  "start": "2020-01-02T00:00:00"
}

POST test/_search
{
  "aggs": {
    "agg1": {
      "date_histogram": {
        "script": {
          "source": "doc['start'].value"
        },
        "calendar_interval": "1y",
        "value_type": "long",
        "time_zone" : "-04"
      }
    }
  }
}

That works without this PR and I feel like it is a valid use-case and it should work. I think we are again dealing with overloaded parameters here.

@imotov
Copy link
Copy Markdown
Contributor

imotov commented Apr 1, 2020

@elasticmachine update branch

@not-napoleon
Copy link
Copy Markdown
Member Author

@elasticmachine test this please

@not-napoleon
Copy link
Copy Markdown
Member Author

@elasticmachine update branch

@not-napoleon
Copy link
Copy Markdown
Member Author

@elasticmachine update branch

Copy link
Copy Markdown
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

LGTM

@not-napoleon not-napoleon merged commit 3fab63a into elastic:master Apr 20, 2020
@not-napoleon not-napoleon deleted the numeric-formatter-fix branch April 20, 2020 15:12
not-napoleon added a commit to not-napoleon/elasticsearch that referenced this pull request Apr 20, 2020
Co-authored-by: Igor Motov <igor@motovs.org>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
not-napoleon added a commit that referenced this pull request Apr 20, 2020
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.

MultiValuesSource Aggregations (including weighted_avg) ignore format

4 participants