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

bugfix: fail to parse elasticsearch mappings #5123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xiacongling
Copy link

What type of PR is this? (check all applicable)

  • Bug Fix

Description

Elasticsearch query_runner may raise TypeError when dynamic setting presents.

e.g. for the following mapping:

{
  "some_datasource": {
    "mappings": {
      "_meta": {...},
      "date_detection":true,
      "_source":Object{...},
      "numeric_detection":false,
      "dynamic_date_formats":[...],
      "dynamic":"true",
      "dynamic_templates":[...],
      "properties":{...}
    }
  },
  .....
}

date_detection and numeric_detection have bool values. BaseElasticSearch._get_query_mappings will raise "TypeError: argument of type 'bool' is not iterable" and fails to return any results for queries.

Check Elasticsearch docs for more details.

This PR add an additional condition check to ignore such fields.

@konnectr
Copy link
Collaborator

konnectr commented Aug 5, 2023

@xiacongling , thanks for the PR!
Do you think the error is relevant ?
We've updated a lot of things now that we're Community-driven so. I'm rebase to master and run ci/cd tests

We're trying to clean up our PR todo list, so if you're not interested, that's fine - we'll close the PR in about a week if we don't hear back. If you're interested in reopening the PR afterwards, we would also very much welcome that.

@konnectr konnectr self-assigned this Aug 5, 2023
@codecov
Copy link

codecov bot commented Aug 5, 2023

Codecov Report

Merging #5123 (748740b) into master (113146e) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #5123      +/-   ##
==========================================
- Coverage   60.73%   60.73%   -0.01%     
==========================================
  Files         153      153              
  Lines       12514    12516       +2     
  Branches     1695     1696       +1     
==========================================
  Hits         7601     7601              
- Misses       4687     4689       +2     
  Partials      226      226              
Files Changed Coverage Δ
redash/query_runner/elasticsearch.py 15.51% <0.00%> (-0.11%) ⬇️

@xiacongling
Copy link
Author

Hi, @konnectr . It looks like the reason for the failure is a loss in test coverage. I'll take a look at it and try to add some test cases later this week. Thanks for the reply!

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

Successfully merging this pull request may close these issues.

None yet

4 participants