SQL: Proper handling of nested fields at the beginning of the columns list (#35068)

This commit is contained in:
Andrei Stefan 2018-10-30 15:52:05 +02:00 committed by GitHub
parent cc4dd98872
commit 253152172c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 105 additions and 3 deletions

View File

@ -44,9 +44,11 @@ class SearchHitRowSet extends AbstractRowSet {
String innerHit = null;
for (HitExtractor ex : exts) {
innerHit = ex.hitName();
if (innerHit != null) {
innerHits.add(innerHit);
if (ex.hitName() != null) {
innerHits.add(ex.hitName());
if (innerHit == null) {
innerHit = ex.hitName();
}
}
}

View File

@ -110,3 +110,103 @@ Chirstian |Koblick
null |Chappelet
Zvonko |Nyanchama
;
//
// Tests for bug https://github.com/elastic/elasticsearch/issues/32951 fix
//
selectNestedFieldFirst
SELECT dep.dep_id, last_name FROM test_emp ORDER BY last_name LIMIT 5;
dep.dep_id:s | last_name:s
d005 |Awdeh
d003 |Azuma
d002 |Baek
d003 |Baek
d004 |Bamford
;
selectNestedFieldLast
SELECT first_name, dep.dep_id FROM test_emp ORDER BY first_name LIMIT 5;
first_name:s | dep.dep_id:s
---------------+---------------
Alejandro |d002
Amabile |d005
Anneke |d005
Anoosh |d005
Arumugam |d008
;
selectNestedFieldInTheMiddle
SELECT first_name, dep.dep_name, last_name FROM test_emp ORDER BY first_name LIMIT 5;
first_name:s |dep.dep_name:s |last_name:s
Alejandro |Finance |McAlpine
Amabile |Development |Gomatam
Anneke |Development |Preusig
Anoosh |Development |Peyn
Arumugam |Research |Ossenbruggen
;
selectNestedFieldInTheMiddleAndAtTheEnd
SELECT first_name, dep.dep_name, last_name, dep.dep_id FROM test_emp ORDER BY first_name LIMIT 5;
first_name:s |dep.dep_name:s | last_name:s | dep.dep_id:s
Alejandro |Finance |McAlpine |d002
Amabile |Development |Gomatam |d005
Anneke |Development |Preusig |d005
Anoosh |Development |Peyn |d005
Arumugam |Research |Ossenbruggen |d008
;
selectNestedFieldInTheMiddleAndAtBeggining
SELECT dep.dep_id, first_name, dep.dep_name, last_name FROM test_emp ORDER BY first_name LIMIT 5;
dep.dep_id:s | first_name:s |dep.dep_name:s | last_name:s
d002 |Alejandro |Finance |McAlpine
d005 |Amabile |Development |Gomatam
d005 |Anneke |Development |Preusig
d005 |Anoosh |Development |Peyn
d008 |Arumugam |Research |Ossenbruggen
;
selectNestedFieldWithWildcardAtBeggining
SELECT dep.*, first_name FROM test_emp ORDER BY first_name LIMIT 5;
dep.dep_id:s |dep.dep_name:s | dep.from_date:ts | dep.to_date:ts | first_name:s
d002 |Finance |1991-06-26T00:00:00.000Z|9999-01-01T00:00:00.000Z|Alejandro
d005 |Development |1992-11-18T00:00:00.000Z|9999-01-01T00:00:00.000Z|Amabile
d005 |Development |1990-08-05T00:00:00.000Z|9999-01-01T00:00:00.000Z|Anneke
d005 |Development |1991-08-30T00:00:00.000Z|9999-01-01T00:00:00.000Z|Anoosh
d008 |Research |1987-04-18T00:00:00.000Z|1997-11-08T00:00:00.000Z|Arumugam
;
selectNestedFieldWithWildcardAtTheEnd
SELECT first_name, dep.* FROM test_emp ORDER BY first_name LIMIT 5;
first_name:s | dep.dep_id:s |dep.dep_name:s | dep.from_date:ts | dep.to_date:ts
Alejandro |d002 |Finance |1991-06-26T00:00:00.000Z|9999-01-01T00:00:00.000Z
Amabile |d005 |Development |1992-11-18T00:00:00.000Z|9999-01-01T00:00:00.000Z
Anneke |d005 |Development |1990-08-05T00:00:00.000Z|9999-01-01T00:00:00.000Z
Anoosh |d005 |Development |1991-08-30T00:00:00.000Z|9999-01-01T00:00:00.000Z
Arumugam |d008 |Research |1987-04-18T00:00:00.000Z|1997-11-08T00:00:00.000Z
;
selectNestedFieldWithWildcardInTheMiddle
SELECT first_name, dep.*, last_name FROM test_emp ORDER BY first_name LIMIT 5;
first_name:s | dep.dep_id:s |dep.dep_name:s | dep.from_date:ts | dep.to_date:ts | last_name:s
Alejandro |d002 |Finance |1991-06-26T00:00:00.000Z|9999-01-01T00:00:00.000Z|McAlpine
Amabile |d005 |Development |1992-11-18T00:00:00.000Z|9999-01-01T00:00:00.000Z|Gomatam
Anneke |d005 |Development |1990-08-05T00:00:00.000Z|9999-01-01T00:00:00.000Z|Preusig
Anoosh |d005 |Development |1991-08-30T00:00:00.000Z|9999-01-01T00:00:00.000Z|Peyn
Arumugam |d008 |Research |1987-04-18T00:00:00.000Z|1997-11-08T00:00:00.000Z|Ossenbruggen
;