Skip to content

Commit

Permalink
Fix more wildcard import statements
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Nov 12, 2024
1 parent 20c9672 commit fb0be94
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
import org.opensearch.sql.data.model.ExprBooleanValue;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.data.type.ExprCoreType;
import org.opensearch.sql.expression.function.*;
import org.opensearch.sql.expression.function.BuiltinFunctionName;
import org.opensearch.sql.expression.function.BuiltinFunctionRepository;
import org.opensearch.sql.expression.function.DefaultFunctionResolver;
import org.opensearch.sql.expression.function.FunctionBuilder;
import org.opensearch.sql.expression.function.FunctionDSL;
import org.opensearch.sql.expression.function.FunctionName;
import org.opensearch.sql.expression.function.FunctionSignature;
import org.opensearch.sql.expression.function.SerializableFunction;

/**
* The definition of unary predicate function not, Accepts one Boolean value and produces a Boolean.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
import static org.opensearch.sql.data.type.ExprCoreType.DATE;
import static org.opensearch.sql.data.type.ExprCoreType.TIMESTAMP;

import java.time.*;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Period;
import java.time.ZoneOffset;
import org.junit.jupiter.api.Test;
import org.opensearch.sql.exception.ExpressionEvaluationException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,29 @@

package org.opensearch.sql.opensearch.data.type;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.opensearch.sql.data.type.ExprCoreType.*;
import static org.opensearch.sql.data.type.ExprCoreType.ARRAY;
import static org.opensearch.sql.data.type.ExprCoreType.BOOLEAN;
import static org.opensearch.sql.data.type.ExprCoreType.BYTE;
import static org.opensearch.sql.data.type.ExprCoreType.DATE;
import static org.opensearch.sql.data.type.ExprCoreType.DOUBLE;
import static org.opensearch.sql.data.type.ExprCoreType.FLOAT;
import static org.opensearch.sql.data.type.ExprCoreType.INTEGER;
import static org.opensearch.sql.data.type.ExprCoreType.LONG;
import static org.opensearch.sql.data.type.ExprCoreType.SHORT;
import static org.opensearch.sql.data.type.ExprCoreType.STRING;
import static org.opensearch.sql.data.type.ExprCoreType.STRUCT;
import static org.opensearch.sql.data.type.ExprCoreType.TIMESTAMP;
import static org.opensearch.sql.data.type.ExprCoreType.UNKNOWN;
import static org.opensearch.sql.opensearch.data.type.OpenSearchDataType.MappingType;

import java.util.Map;
Expand All @@ -34,6 +54,28 @@ class OpenSearchDataTypeTest {

private static final OpenSearchDateType dateType = OpenSearchDateType.of(emptyFormatString);

private static Stream<Arguments> getTestDataWithType() {
return Stream.of(
Arguments.of(MappingType.Text, "text", OpenSearchTextType.of()),
Arguments.of(MappingType.Keyword, "keyword", STRING),
Arguments.of(MappingType.Byte, "byte", BYTE),
Arguments.of(MappingType.Short, "short", SHORT),
Arguments.of(MappingType.Integer, "integer", INTEGER),
Arguments.of(MappingType.Long, "long", LONG),
Arguments.of(MappingType.HalfFloat, "half_float", FLOAT),
Arguments.of(MappingType.Float, "float", FLOAT),
Arguments.of(MappingType.ScaledFloat, "scaled_float", DOUBLE),
Arguments.of(MappingType.Double, "double", DOUBLE),
Arguments.of(MappingType.Boolean, "boolean", BOOLEAN),
Arguments.of(MappingType.Date, "timestamp", TIMESTAMP),
Arguments.of(MappingType.DateNanos, "timestamp", TIMESTAMP),
Arguments.of(MappingType.Object, "object", STRUCT),
Arguments.of(MappingType.Nested, "nested", ARRAY),
Arguments.of(MappingType.GeoPoint, "geo_point", OpenSearchGeoPointType.of()),
Arguments.of(MappingType.Binary, "binary", OpenSearchBinaryType.of()),
Arguments.of(MappingType.Ip, "ip", STRING));
}

@Test
public void isCompatible() {
assertTrue(STRING.isCompatible(textType));
Expand Down Expand Up @@ -71,28 +113,6 @@ public void shouldCast() {
assertFalse(textKeywordType.shouldCast(STRING));
}

private static Stream<Arguments> getTestDataWithType() {
return Stream.of(
Arguments.of(MappingType.Text, "text", OpenSearchTextType.of()),
Arguments.of(MappingType.Keyword, "keyword", STRING),
Arguments.of(MappingType.Byte, "byte", BYTE),
Arguments.of(MappingType.Short, "short", SHORT),
Arguments.of(MappingType.Integer, "integer", INTEGER),
Arguments.of(MappingType.Long, "long", LONG),
Arguments.of(MappingType.HalfFloat, "half_float", FLOAT),
Arguments.of(MappingType.Float, "float", FLOAT),
Arguments.of(MappingType.ScaledFloat, "scaled_float", DOUBLE),
Arguments.of(MappingType.Double, "double", DOUBLE),
Arguments.of(MappingType.Boolean, "boolean", BOOLEAN),
Arguments.of(MappingType.Date, "timestamp", TIMESTAMP),
Arguments.of(MappingType.DateNanos, "timestamp", TIMESTAMP),
Arguments.of(MappingType.Object, "object", STRUCT),
Arguments.of(MappingType.Nested, "nested", ARRAY),
Arguments.of(MappingType.GeoPoint, "geo_point", OpenSearchGeoPointType.of()),
Arguments.of(MappingType.Binary, "binary", OpenSearchBinaryType.of()),
Arguments.of(MappingType.Ip, "ip", STRING));
}

@ParameterizedTest(name = "{1}")
@MethodSource("getTestDataWithType")
public void of_MappingType(MappingType mappingType, String name, ExprType dataType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

package org.opensearch.sql.opensearch.data.value;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
import org.opensearch.sql.opensearch.data.type.OpenSearchIpType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,34 @@

package org.opensearch.sql.opensearch.data.value;

import static org.junit.jupiter.api.Assertions.*;
import static org.opensearch.sql.data.model.ExprValueUtils.*;
import static org.opensearch.sql.data.type.ExprCoreType.*;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opensearch.sql.data.model.ExprValueUtils.booleanValue;
import static org.opensearch.sql.data.model.ExprValueUtils.byteValue;
import static org.opensearch.sql.data.model.ExprValueUtils.collectionValue;
import static org.opensearch.sql.data.model.ExprValueUtils.doubleValue;
import static org.opensearch.sql.data.model.ExprValueUtils.floatValue;
import static org.opensearch.sql.data.model.ExprValueUtils.integerValue;
import static org.opensearch.sql.data.model.ExprValueUtils.longValue;
import static org.opensearch.sql.data.model.ExprValueUtils.nullValue;
import static org.opensearch.sql.data.model.ExprValueUtils.shortValue;
import static org.opensearch.sql.data.model.ExprValueUtils.stringValue;
import static org.opensearch.sql.data.type.ExprCoreType.ARRAY;
import static org.opensearch.sql.data.type.ExprCoreType.BOOLEAN;
import static org.opensearch.sql.data.type.ExprCoreType.BYTE;
import static org.opensearch.sql.data.type.ExprCoreType.DATE;
import static org.opensearch.sql.data.type.ExprCoreType.DOUBLE;
import static org.opensearch.sql.data.type.ExprCoreType.FLOAT;
import static org.opensearch.sql.data.type.ExprCoreType.INTEGER;
import static org.opensearch.sql.data.type.ExprCoreType.LONG;
import static org.opensearch.sql.data.type.ExprCoreType.SHORT;
import static org.opensearch.sql.data.type.ExprCoreType.STRING;
import static org.opensearch.sql.data.type.ExprCoreType.STRUCT;
import static org.opensearch.sql.data.type.ExprCoreType.TIME;
import static org.opensearch.sql.data.type.ExprCoreType.TIMESTAMP;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -24,7 +49,13 @@
import org.junit.jupiter.api.Test;
import org.opensearch.OpenSearchParseException;
import org.opensearch.geometry.utils.Geohash;
import org.opensearch.sql.data.model.*;
import org.opensearch.sql.data.model.ExprCollectionValue;
import org.opensearch.sql.data.model.ExprDateValue;
import org.opensearch.sql.data.model.ExprStringValue;
import org.opensearch.sql.data.model.ExprTimeValue;
import org.opensearch.sql.data.model.ExprTimestampValue;
import org.opensearch.sql.data.model.ExprTupleValue;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.opensearch.data.type.OpenSearchDataType;
import org.opensearch.sql.opensearch.data.type.OpenSearchDateType;
import org.opensearch.sql.opensearch.data.type.OpenSearchTextType;
Expand Down Expand Up @@ -88,10 +119,9 @@ class OpenSearchExprValueFactoryTest {
.put("geoV", OpenSearchDataType.of(OpenSearchDataType.MappingType.GeoPoint))
.put("binaryV", OpenSearchDataType.of(OpenSearchDataType.MappingType.Binary))
.build();

private static final double TOLERANCE = 1E-5;
private final OpenSearchExprValueFactory exprValueFactory =
new OpenSearchExprValueFactory(MAPPING, true);

private final OpenSearchExprValueFactory exprValueFactoryNoArrays =
new OpenSearchExprValueFactory(MAPPING, false);

Expand Down Expand Up @@ -726,8 +756,6 @@ public void constructIP() {
assertEquals(stringValue(valueIpv6), constructFromObject(fieldIp, valueIpv6));
}

private static final double TOLERANCE = 1E-5;

@Test
public void constructGeoPoint() {
final double lat = 42.60355556;
Expand Down

0 comments on commit fb0be94

Please sign in to comment.