Skip to content

Commit e1fcfa5

Browse files
LantaoJinxinyual
authored andcommitted
Followup: Register OpenSearchTypeSystem to OpenSearchTypeFactory (#3349)
Signed-off-by: Lantao Jin <ltjin@amazon.com> Signed-off-by: xinyual <xinyual@amazon.com>
1 parent 532670d commit e1fcfa5

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

core/src/main/java/org/opensearch/sql/calcite/utils/OpenSearchTypeFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@
3333
import org.opensearch.sql.data.model.ExprValueUtils;
3434
import org.opensearch.sql.data.type.ExprCoreType;
3535
import org.opensearch.sql.data.type.ExprType;
36+
import org.opensearch.sql.executor.OpenSearchTypeSystem;
3637
import org.opensearch.sql.storage.Table;
3738

3839
/** This class is used to create RelDataType and map RelDataType to Java data type */
3940
public class OpenSearchTypeFactory extends JavaTypeFactoryImpl {
4041
public static final OpenSearchTypeFactory TYPE_FACTORY =
41-
new OpenSearchTypeFactory(RelDataTypeSystem.DEFAULT);
42+
new OpenSearchTypeFactory(OpenSearchTypeSystem.INSTANCE);
4243

4344
private OpenSearchTypeFactory(RelDataTypeSystem typeSystem) {
4445
super(typeSystem);

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ public class OpenSearchTypeSystem extends RelDataTypeSystemImpl {
1616

1717
private OpenSearchTypeSystem() {}
1818

19+
@Override
1920
public RelDataType deriveAvgAggType(RelDataTypeFactory typeFactory, RelDataType argumentType) {
20-
switch (argumentType.getSqlTypeName()) {
21-
case INTEGER:
22-
case BIGINT:
23-
return typeFactory.createSqlType(SqlTypeName.DOUBLE);
24-
25-
default:
26-
return super.deriveSumType(typeFactory, argumentType);
21+
if (SqlTypeName.INT_TYPES.contains(argumentType.getSqlTypeName())) {
22+
return typeFactory.createTypeWithNullability(
23+
typeFactory.createSqlType(SqlTypeName.DOUBLE), false);
24+
} else {
25+
return argumentType;
2726
}
2827
}
2928
}

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalcitePPLSortIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
99

1010
import java.io.IOException;
11+
import org.junit.Ignore;
1112
import org.junit.jupiter.api.Test;
1213

1314
/** testSortXXAndXX could fail. TODO Remove this @Ignore when the issue fixed. */
14-
// @Ignore
15+
@Ignore
1516
public class CalcitePPLSortIT extends CalcitePPLIntegTestCase {
1617

1718
@Override

0 commit comments

Comments
 (0)