Skip to content

Commit bc38f9f

Browse files
committed
Enable identifier expansion to ensure that casted args in agg functions are passed on
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 975d21c commit bc38f9f

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

core/src/main/java/org/opensearch/sql/calcite/CalcitePlanContext.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ public SqlValidator getValidator() {
145145
// Use lenient conformance for PPL compatibility
146146
.withConformance(OpenSearchSparkSqlDialect.DEFAULT.getConformance())
147147
// Use Spark SQL's NULL collation (NULLs sorted LOW/FIRST)
148-
.withDefaultNullCollation(NullCollation.LOW);
148+
.withDefaultNullCollation(NullCollation.LOW)
149+
// This ensures that coerced arguments are replaced with cast version in sql select
150+
// list because coercion is performed during select list expansion during sql
151+
// validation. Affects 4356.yml
152+
// See SqlValidatorImpl#validateSelectList and AggConverter#translateAgg
153+
.withIdentifierExpansion(true);
149154
validator =
150155
PplValidator.create(
151156
statement,

core/src/main/java/org/opensearch/sql/executor/QueryService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private RelNode validate(RelNode relNode, CalcitePlanContext context) {
318318
SqlNode rewritten = root.accept(new SqlRewriteShuttle());
319319
SqlValidator validator = context.getValidator();
320320
try {
321-
validator.validate(Objects.requireNonNull(rewritten));
321+
validator.validate(Objects.requireNonNull(rewritten));
322322
} catch (CalciteContextException e) {
323323
if (ValidationUtils.tolerantValidationException(e)) {
324324
return relNode;

0 commit comments

Comments
 (0)