diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java index 95815d5c38..22a43d3444 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprValueFactory.java @@ -105,7 +105,7 @@ public void extendTypeMapping(Map typeMapping) { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - private static final Map> typeActionMap = + private final Map> typeActionMap = new ImmutableMap.Builder>() .put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Integer), (c, dt) -> new ExprIntegerValue(c.intValue())) @@ -126,12 +126,10 @@ public void extendTypeMapping(Map typeMapping) { .put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Boolean), (c, dt) -> ExprBooleanValue.of(c.booleanValue())) //Handles the creation of DATE, TIME & DATETIME - .put(OpenSearchDateType.of(TIME), OpenSearchExprValueFactory::createOpenSearchDateType) - .put(OpenSearchDateType.of(DATE), OpenSearchExprValueFactory::createOpenSearchDateType) - .put(OpenSearchDateType.of(TIMESTAMP), - OpenSearchExprValueFactory::createOpenSearchDateType) - .put(OpenSearchDateType.of(DATETIME), - OpenSearchExprValueFactory::createOpenSearchDateType) + .put(OpenSearchDateType.of(TIME), this::createOpenSearchDateType) + .put(OpenSearchDateType.of(DATE), this::createOpenSearchDateType) + .put(OpenSearchDateType.of(TIMESTAMP), this::createOpenSearchDateType) + .put(OpenSearchDateType.of(DATETIME), this::createOpenSearchDateType) .put(OpenSearchDataType.of(OpenSearchDataType.MappingType.Ip), (c, dt) -> new OpenSearchExprIpValue(c.stringValue())) .put(OpenSearchDataType.of(OpenSearchDataType.MappingType.GeoPoint), @@ -224,7 +222,7 @@ private Optional type(String field) { * @param dataType - field data type * @return Parsed value */ - private static ExprValue parseDateTimeString(String value, OpenSearchDateType dataType) { + private ExprValue parseDateTimeString(String value, OpenSearchDateType dataType) { List formatters = dataType.getAllNamedFormatters(); formatters.addAll(dataType.getAllCustomFormatters()); ExprCoreType returnFormat = (ExprCoreType) dataType.getExprType(); @@ -264,7 +262,7 @@ private static ExprValue parseDateTimeString(String value, OpenSearchDateType da "Construct %s from \"%s\" failed, unsupported format.", returnFormat, value)); } - private static ExprValue createOpenSearchDateType(Content value, ExprType type) { + private ExprValue createOpenSearchDateType(Content value, ExprType type) { OpenSearchDateType dt = (OpenSearchDateType) type; ExprType returnFormat = dt.getExprType();