Skip to content

Commit 842e9d1

Browse files
committed
Cover a flat_object declared as a sub-field of an object
The field type's documentation shows this as its second example, and the tests only had one at the top level. The leaf is then named by the whole path and the index term carries all of it, so the lookup is the same term query -- which is what the explain assertion checks, since the path is assembled from the column name rather than being a single segment. Signed-off-by: Jialiang Liang <jiallian@amazon.com>
1 parent 74aa8b8 commit 842e9d1

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

  • integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues

‎integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/1604.yml‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,61 @@ teardown:
194194
body:
195195
query: "source=otel | where like(attributes.duration_ms, '1%') | fields service"
196196
- match: {"calcite.physical": "/\"wildcard\":\\{\"attributes.duration_ms\"/"}
197+
198+
---
199+
# A flat_object can be a sub-field of an ordinary object, which the field type's documentation shows
200+
# as its second example. The leaf is then named by the whole path, and the index term carries all of
201+
# it, so the lookup is the same one.
202+
"a flat_object can be a sub-field of an object":
203+
- skip:
204+
features: [headers]
205+
- do:
206+
indices.create:
207+
index: sub
208+
body:
209+
settings:
210+
number_of_shards: 1
211+
number_of_replicas: 0
212+
mappings:
213+
properties:
214+
issue:
215+
properties:
216+
number:
217+
type: double
218+
labels:
219+
type: flat_object
220+
- do:
221+
index:
222+
index: sub
223+
id: 1
224+
refresh: true
225+
body: {"issue": {"number": 123456, "labels": {"version": "2.1", "backport": ["2.0", "1.3"], "category": {"type": "API", "level": "enhancement"}}}}
226+
# the sibling keeps its own mapping; only labels is flat
227+
- do:
228+
headers: {Content-Type: 'application/json'}
229+
ppl:
230+
body:
231+
query: 'describe sub | fields COLUMN_NAME, TYPE_NAME'
232+
- match: {"datarows": [["issue", "struct"], ["issue.labels", "flat_object"], ["issue.number", "double"]]}
233+
- do:
234+
headers: {Content-Type: 'application/json'}
235+
ppl:
236+
body:
237+
query: 'source=sub | fields issue.labels.category.level, issue.labels.backport, issue.number'
238+
- match: {"datarows": [["enhancement", "[\"2.0\",\"1.3\"]", 123456.0]]}
239+
# the term the index holds carries the whole path, so the lookup is a term like any other
240+
- do:
241+
headers: {Content-Type: 'application/json'}
242+
ppl:
243+
body:
244+
query: 'source=sub | where issue.labels.category.level = ''enhancement'' | fields issue.number'
245+
- match: {"datarows": [[123456.0]]}
246+
- do:
247+
headers: {Content-Type: 'application/json'}
248+
ppl.explain:
249+
body:
250+
query: "source=sub | where issue.labels.category.level = 'enhancement' | fields issue.number"
251+
- match: {"calcite.physical": "/\"term\":\\{\"issue.labels.category.level\"/"}
252+
- do:
253+
indices.delete:
254+
index: sub

0 commit comments

Comments
 (0)