Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ private RelNode handleAllFieldsProject(Project node, CalcitePlanContext context)
"Invalid field exclusion: operation would exclude all fields from the result set");
}
AllFields allFields = (AllFields) node.getProjectList().getFirst();
if (!(allFields instanceof AllFieldsExcludeMeta)) {
// Should not remove nested fields for AllFieldsExcludeMeta.
if (!(allFields instanceof AllFieldsExcludeMeta) && !context.isProjectVisited()) {
// Should not remove nested fields for AllFieldsExcludeMeta
// and when no explicit project has already curated the schema
tryToRemoveNestedFields(context);
}
tryToRemoveMetaFields(context, allFields instanceof AllFieldsExcludeMeta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_TELEMETRY;
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_DEEP_NESTED;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
Expand Down Expand Up @@ -233,4 +234,12 @@ public void testEvalStringConcatenationWithExistingData() throws IOException {
rows("Hattie", "Bond", "Hattie Bond"),
rows("Nanette", "Bates", "Nanette Bates"));
}

@Test
public void testStruckFieldAndSubFieldWithHead() throws IOException {
JSONObject result =
executeQuery(
String.format("source=%s | fields city.name, city | head", TEST_INDEX_DEEP_NESTED));
verifySchema(result, schema("city.name", "string"), schema("city", "struct"));
}
}
Loading