Skip to content

Commit ba80882

Browse files
committed
Correct why a script over a flat_object is refused
The comment claimed the field type does not support Painless for retrieving subfield values. That is a limitation of doc-value access; this engine's script reads _source, and it does retrieve flat_object leaves correctly -- a sort over one returns the right order. The reason to refuse is the cost of that read, not an inability, and the types above are read from _source on purpose, so the comment now says which of the two this is. Signed-off-by: Jialiang Liang <jiallian@amazon.com>
1 parent 99e5316 commit ba80882

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎opensearch/src/main/java/org/opensearch/sql/opensearch/storage/serde/RexStandardizer.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ public RexNode visitInputRef(RexInputRef inputRef, ScriptParameterHelper helper)
117117
? null
118118
: OpenSearchTextType.toKeywordSubField(field.getName(), exprType);
119119
if (exprType instanceof OpenSearchFlatObjectType) {
120-
// A flat_object has no usable doc values (each is the folded path=value term), so a script
121-
// could only read it from _source, which means opening every record -- and the field type
122-
// does not support Painless for retrieving subfield values either.
120+
// Each leaf is indexed as one folded path=value term, so a flat_object has no doc values a
121+
// script could read: it would have to open _source for every record it is asked about, the
122+
// cost the field type exists to avoid. A script over one is refused rather than built, unlike
123+
// the no-doc-values types above, which are read from _source that way on purpose.
123124
throw new UnsupportedScriptException(
124125
"A flat_object field cannot be read by a pushed-down script: " + field.getName());
125126
}

0 commit comments

Comments
 (0)