diff --git a/build.gradle b/build.gradle index e7cbd5b988..2726cb609e 100644 --- a/build.gradle +++ b/build.gradle @@ -83,18 +83,18 @@ repositories { // Spotless checks will be added as PRs are applied to resolve each style issue is approved. spotless { java { -// target fileTree('.') { -// include '**/*.java', 'src/*/java/**/*.java' -// exclude '**/build/**', '**/build-*/**' -// } + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } // importOrder() // licenseHeader("/*\n" + // " * Copyright OpenSearch Contributors\n" + // " * SPDX-License-Identifier: Apache-2.0\n" + -// " */\n\n\n") +// " */\n\n") // removeUnusedImports() // trimTrailingWhitespace() -// endWithNewline() + endWithNewline() // googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') } } diff --git a/common/src/main/java/org/opensearch/sql/common/grok/Converter.java b/common/src/main/java/org/opensearch/sql/common/grok/Converter.java index 72bfa3d7f1..ebbe13f761 100644 --- a/common/src/main/java/org/opensearch/sql/common/grok/Converter.java +++ b/common/src/main/java/org/opensearch/sql/common/grok/Converter.java @@ -1,168 +1,168 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.opensearch.sql.common.grok; - -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.temporal.TemporalAccessor; -import java.util.AbstractMap; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * Convert String argument to the right type. - */ -public class Converter { - - public enum Type { - BYTE(Byte::valueOf), - BOOLEAN(Boolean::valueOf), - SHORT(Short::valueOf), - INT(Integer::valueOf, "integer"), - LONG(Long::valueOf), - FLOAT(Float::valueOf), - DOUBLE(Double::valueOf), - DATETIME(new DateConverter(), "date"), - STRING(v -> v, "text"); - - public final IConverter converter; - public final List aliases; - - Type(IConverter converter, String... aliases) { - this.converter = converter; - this.aliases = Arrays.asList(aliases); - } - } - - private static final Pattern SPLITTER = Pattern.compile("[:;]"); - - private static final Map TYPES = - Arrays.stream(Type.values()) - .collect(Collectors.toMap(t -> t.name().toLowerCase(), t -> t)); - - private static final Map TYPE_ALIASES = - Arrays.stream(Type.values()) - .flatMap(type -> type.aliases.stream() - .map(alias -> new AbstractMap.SimpleEntry<>(alias, type))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - private static Type getType(String key) { - key = key.toLowerCase(); - Type type = TYPES.getOrDefault(key, TYPE_ALIASES.get(key)); - if (type == null) { - throw new IllegalArgumentException("Invalid data type :" + key); - } - return type; - } - - /** - * getConverters. - */ - public static Map> - getConverters(Collection groupNames, Object... params) { - return groupNames.stream() - .filter(Converter::containsDelimiter) - .collect(Collectors.toMap(Function.identity(), key -> { - String[] list = splitGrokPattern(key); - IConverter converter = getType(list[1]).converter; - if (list.length == 3) { - converter = converter.newConverter(list[2], params); - } - return converter; - })); - } - - /** - * getGroupTypes. - */ - public static Map getGroupTypes(Collection groupNames) { - return groupNames.stream() - .filter(Converter::containsDelimiter) - .map(Converter::splitGrokPattern) - .collect(Collectors.toMap( - l -> l[0], - l -> getType(l[1]) - )); - } - - public static String extractKey(String key) { - return splitGrokPattern(key)[0]; - } - - private static boolean containsDelimiter(String string) { - return string.indexOf(':') >= 0 || string.indexOf(';') >= 0; - } - - private static String[] splitGrokPattern(String string) { - return SPLITTER.split(string, 3); - } - - interface IConverter { - - T convert(String value); - - default IConverter newConverter(String param, Object... params) { - return this; - } - } - - - static class DateConverter implements IConverter { - - private final DateTimeFormatter formatter; - private final ZoneId timeZone; - - public DateConverter() { - this.formatter = DateTimeFormatter.ISO_DATE_TIME; - this.timeZone = ZoneOffset.UTC; - } - - private DateConverter(DateTimeFormatter formatter, ZoneId timeZone) { - this.formatter = formatter; - this.timeZone = timeZone; - } - - @Override - public Instant convert(String value) { - TemporalAccessor dt = formatter - .parseBest(value.trim(), ZonedDateTime::from, LocalDateTime::from, OffsetDateTime::from, - Instant::from, - LocalDate::from); - if (dt instanceof ZonedDateTime) { - return ((ZonedDateTime) dt).toInstant(); - } else if (dt instanceof LocalDateTime) { - return ((LocalDateTime) dt).atZone(timeZone).toInstant(); - } else if (dt instanceof OffsetDateTime) { - return ((OffsetDateTime) dt).atZoneSameInstant(timeZone).toInstant(); - } else if (dt instanceof Instant) { - return ((Instant) dt); - } else if (dt instanceof LocalDate) { - return ((LocalDate) dt).atStartOfDay(timeZone).toInstant(); - } else { - return null; - } - } - - @Override - public DateConverter newConverter(String param, Object... params) { - if (!(params.length == 1 && params[0] instanceof ZoneId)) { - throw new IllegalArgumentException("Invalid parameters"); - } - return new DateConverter(DateTimeFormatter.ofPattern(param), (ZoneId) params[0]); - } - } -} +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.opensearch.sql.common.grok; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * Convert String argument to the right type. + */ +public class Converter { + + public enum Type { + BYTE(Byte::valueOf), + BOOLEAN(Boolean::valueOf), + SHORT(Short::valueOf), + INT(Integer::valueOf, "integer"), + LONG(Long::valueOf), + FLOAT(Float::valueOf), + DOUBLE(Double::valueOf), + DATETIME(new DateConverter(), "date"), + STRING(v -> v, "text"); + + public final IConverter converter; + public final List aliases; + + Type(IConverter converter, String... aliases) { + this.converter = converter; + this.aliases = Arrays.asList(aliases); + } + } + + private static final Pattern SPLITTER = Pattern.compile("[:;]"); + + private static final Map TYPES = + Arrays.stream(Type.values()) + .collect(Collectors.toMap(t -> t.name().toLowerCase(), t -> t)); + + private static final Map TYPE_ALIASES = + Arrays.stream(Type.values()) + .flatMap(type -> type.aliases.stream() + .map(alias -> new AbstractMap.SimpleEntry<>(alias, type))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + private static Type getType(String key) { + key = key.toLowerCase(); + Type type = TYPES.getOrDefault(key, TYPE_ALIASES.get(key)); + if (type == null) { + throw new IllegalArgumentException("Invalid data type :" + key); + } + return type; + } + + /** + * getConverters. + */ + public static Map> + getConverters(Collection groupNames, Object... params) { + return groupNames.stream() + .filter(Converter::containsDelimiter) + .collect(Collectors.toMap(Function.identity(), key -> { + String[] list = splitGrokPattern(key); + IConverter converter = getType(list[1]).converter; + if (list.length == 3) { + converter = converter.newConverter(list[2], params); + } + return converter; + })); + } + + /** + * getGroupTypes. + */ + public static Map getGroupTypes(Collection groupNames) { + return groupNames.stream() + .filter(Converter::containsDelimiter) + .map(Converter::splitGrokPattern) + .collect(Collectors.toMap( + l -> l[0], + l -> getType(l[1]) + )); + } + + public static String extractKey(String key) { + return splitGrokPattern(key)[0]; + } + + private static boolean containsDelimiter(String string) { + return string.indexOf(':') >= 0 || string.indexOf(';') >= 0; + } + + private static String[] splitGrokPattern(String string) { + return SPLITTER.split(string, 3); + } + + interface IConverter { + + T convert(String value); + + default IConverter newConverter(String param, Object... params) { + return this; + } + } + + + static class DateConverter implements IConverter { + + private final DateTimeFormatter formatter; + private final ZoneId timeZone; + + public DateConverter() { + this.formatter = DateTimeFormatter.ISO_DATE_TIME; + this.timeZone = ZoneOffset.UTC; + } + + private DateConverter(DateTimeFormatter formatter, ZoneId timeZone) { + this.formatter = formatter; + this.timeZone = timeZone; + } + + @Override + public Instant convert(String value) { + TemporalAccessor dt = formatter + .parseBest(value.trim(), ZonedDateTime::from, LocalDateTime::from, OffsetDateTime::from, + Instant::from, + LocalDate::from); + if (dt instanceof ZonedDateTime) { + return ((ZonedDateTime) dt).toInstant(); + } else if (dt instanceof LocalDateTime) { + return ((LocalDateTime) dt).atZone(timeZone).toInstant(); + } else if (dt instanceof OffsetDateTime) { + return ((OffsetDateTime) dt).atZoneSameInstant(timeZone).toInstant(); + } else if (dt instanceof Instant) { + return ((Instant) dt); + } else if (dt instanceof LocalDate) { + return ((LocalDate) dt).atStartOfDay(timeZone).toInstant(); + } else { + return null; + } + } + + @Override + public DateConverter newConverter(String param, Object... params) { + if (!(params.length == 1 && params[0] instanceof ZoneId)) { + throw new IllegalArgumentException("Invalid parameters"); + } + return new DateConverter(DateTimeFormatter.ofPattern(param), (ZoneId) params[0]); + } + } +} diff --git a/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java b/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java index c884afd86a..407d37e8e4 100644 --- a/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java +++ b/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java @@ -57,4 +57,3 @@ public enum CommandType { RARE } } - diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java index 1f4ac3943c..e25c5cda20 100644 --- a/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/ArithmeticFunction.java @@ -265,4 +265,4 @@ private static DefaultFunctionResolver subtract() { private static DefaultFunctionResolver subtractFunction() { return subtractBase(BuiltinFunctionName.SUBTRACTFUNCTION.getName()); } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java b/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java index e56c85a0c8..0bbfb65154 100644 --- a/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/text/TextFunction.java @@ -379,4 +379,3 @@ private static ExprValue exprReverse(ExprValue str) { return new ExprStringValue(new StringBuilder(str.stringValue()).reverse().toString()); } } - diff --git a/core/src/test/java/org/opensearch/sql/planner/logical/LogicalRelationTest.java b/core/src/test/java/org/opensearch/sql/planner/logical/LogicalRelationTest.java index dacd84e12b..6426ebb63f 100644 --- a/core/src/test/java/org/opensearch/sql/planner/logical/LogicalRelationTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/logical/LogicalRelationTest.java @@ -33,4 +33,4 @@ public void logicalRelationWithDataSourceHasNoInput() { assertEquals(0, relation.getChild().size()); } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/opensearch/sql/planner/streaming/watermark/BoundedOutOfOrderWatermarkGeneratorTest.java b/core/src/test/java/org/opensearch/sql/planner/streaming/watermark/BoundedOutOfOrderWatermarkGeneratorTest.java index 1d18a16f2a..9522c600b8 100644 --- a/core/src/test/java/org/opensearch/sql/planner/streaming/watermark/BoundedOutOfOrderWatermarkGeneratorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/streaming/watermark/BoundedOutOfOrderWatermarkGeneratorTest.java @@ -58,4 +58,4 @@ public AssertionHelper shouldGenerateWatermark(long expected) { return this; } } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/WindowTest.java b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/WindowTest.java index 9b9aafa933..c8214f5771 100644 --- a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/WindowTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/WindowTest.java @@ -18,4 +18,4 @@ void test() { assertEquals(2000, window.getEndTime()); assertEquals(1999, window.maxTimestamp()); } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/SlidingWindowAssignerTest.java b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/SlidingWindowAssignerTest.java index fd69065742..886537e088 100644 --- a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/SlidingWindowAssignerTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/SlidingWindowAssignerTest.java @@ -49,4 +49,4 @@ void testConstructWithIllegalArguments() { () -> new SlidingWindowAssigner(1000, 0)); assertEquals("Slide size [0] must be positive number", error2.getMessage()); } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssignerTest.java b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssignerTest.java index 4c98c40f7a..55a8750c11 100644 --- a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssignerTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssignerTest.java @@ -36,4 +36,4 @@ void testConstructWithIllegalWindowSize() { () -> new TumblingWindowAssigner(-1)); assertEquals("Window size [-1] must be positive number", error.getMessage()); } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/trigger/AfterWatermarkWindowTriggerTest.java b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/trigger/AfterWatermarkWindowTriggerTest.java index 3ef6907c38..d2854549ae 100644 --- a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/trigger/AfterWatermarkWindowTriggerTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/trigger/AfterWatermarkWindowTriggerTest.java @@ -31,4 +31,4 @@ void shouldFireWindowBelowWatermark() { assertEquals(TriggerResult.FIRE, trigger.trigger(new Window(500, 800))); assertEquals(TriggerResult.FIRE, trigger.trigger(new Window(500, 1000))); } -} \ No newline at end of file +} diff --git a/core/src/test/java/org/opensearch/sql/storage/write/TableWriteOperatorTest.java b/core/src/test/java/org/opensearch/sql/storage/write/TableWriteOperatorTest.java index 8780b08276..112192bde0 100644 --- a/core/src/test/java/org/opensearch/sql/storage/write/TableWriteOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/storage/write/TableWriteOperatorTest.java @@ -67,4 +67,4 @@ public Boolean visitTableWrite(TableWriteOperator node, Object context) { void testGetChild() { assertEquals(Collections.singletonList(child), tableWrite.getChild()); } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/encryptor/Encryptor.java b/datasources/src/main/java/org/opensearch/sql/datasources/encryptor/Encryptor.java index 55dc1ef18f..578b66d0ba 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/encryptor/Encryptor.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/encryptor/Encryptor.java @@ -25,4 +25,4 @@ public interface Encryptor { */ String decrypt(String encryptedText); -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/encryptor/EncryptorImpl.java b/datasources/src/main/java/org/opensearch/sql/datasources/encryptor/EncryptorImpl.java index 18e3e2f257..98f693eca1 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/encryptor/EncryptorImpl.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/encryptor/EncryptorImpl.java @@ -67,4 +67,4 @@ private void validate(String masterKey) { } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/CreateDataSourceActionRequest.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/CreateDataSourceActionRequest.java index 2926f95220..0cbb2355ca 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/CreateDataSourceActionRequest.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/CreateDataSourceActionRequest.java @@ -46,4 +46,4 @@ public ActionRequestValidationException validate() { return null; } } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/CreateDataSourceActionResponse.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/CreateDataSourceActionResponse.java index 3b997a7d21..377a249a44 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/CreateDataSourceActionResponse.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/CreateDataSourceActionResponse.java @@ -30,4 +30,4 @@ public CreateDataSourceActionResponse(StreamInput in) throws IOException { public void writeTo(StreamOutput streamOutput) throws IOException { streamOutput.writeString(result); } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DeleteDataSourceActionRequest.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DeleteDataSourceActionRequest.java index bc9d4491d5..1eb2d17bff 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DeleteDataSourceActionRequest.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DeleteDataSourceActionRequest.java @@ -48,4 +48,4 @@ public ActionRequestValidationException validate() { } } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DeleteDataSourceActionResponse.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DeleteDataSourceActionResponse.java index 11d4a72274..4bb6e290c5 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DeleteDataSourceActionResponse.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/DeleteDataSourceActionResponse.java @@ -30,4 +30,4 @@ public void writeTo(StreamOutput streamOutput) throws IOException { streamOutput.writeString(result); } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/GetDataSourceActionRequest.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/GetDataSourceActionRequest.java index 1e617f1866..23f4898543 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/GetDataSourceActionRequest.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/GetDataSourceActionRequest.java @@ -46,4 +46,4 @@ public ActionRequestValidationException validate() { } } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/GetDataSourceActionResponse.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/GetDataSourceActionResponse.java index 15437e6a3f..964e5989f8 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/GetDataSourceActionResponse.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/GetDataSourceActionResponse.java @@ -30,4 +30,4 @@ public void writeTo(StreamOutput streamOutput) throws IOException { streamOutput.writeString(result); } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionRequest.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionRequest.java index cd5c761d85..11bc2d1e20 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionRequest.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionRequest.java @@ -44,4 +44,4 @@ public ActionRequestValidationException validate() { return null; } } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionResponse.java b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionResponse.java index 8407b9675d..5f5f6f496a 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionResponse.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/model/transport/UpdateDataSourceActionResponse.java @@ -30,4 +30,4 @@ public UpdateDataSourceActionResponse(StreamInput in) throws IOException { public void writeTo(StreamOutput streamOutput) throws IOException { streamOutput.writeString(result); } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java index aa34488675..a56512f838 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/rest/RestDataSourceQueryAction.java @@ -251,4 +251,4 @@ private static boolean isClientError(Exception e) { || e instanceof IllegalStateException; } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/service/DataSourceMetadataStorage.java b/datasources/src/main/java/org/opensearch/sql/datasources/service/DataSourceMetadataStorage.java index b54af3195e..e6483900c6 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/service/DataSourceMetadataStorage.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/service/DataSourceMetadataStorage.java @@ -60,4 +60,4 @@ public interface DataSourceMetadataStorage { */ void deleteDataSourceMetadata(String datasourceName); -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceAction.java index 4d8c51fac7..ce1c1bb157 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceAction.java @@ -57,4 +57,4 @@ protected void doExecute(Task task, CreateDataSourceActionRequest request, } } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceAction.java index 1d109ca7fc..fe2df1ee51 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceAction.java @@ -56,4 +56,4 @@ protected void doExecute(Task task, DeleteDataSourceActionRequest request, } } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceAction.java index 33d08f7cd2..7a36114755 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceAction.java @@ -92,4 +92,4 @@ protected Object buildJsonObject(DataSourceMetadata response) { }.format(dataSourceMetadata); return responseContent; } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceAction.java index 4aece69e5b..13f80733e6 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceAction.java @@ -56,4 +56,4 @@ protected void doExecute(Task task, UpdateDataSourceActionRequest request, } } -} \ No newline at end of file +} diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/utils/Scheduler.java b/datasources/src/main/java/org/opensearch/sql/datasources/utils/Scheduler.java index 0bc597ed4f..eaac8a7fa3 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/utils/Scheduler.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/utils/Scheduler.java @@ -30,4 +30,4 @@ private static Runnable withCurrentContext(final Runnable task) { task.run(); }; } -} \ No newline at end of file +} diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/encryptor/EncryptorImplTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/encryptor/EncryptorImplTest.java index 8c9b140f09..d62a5a957a 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/encryptor/EncryptorImplTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/encryptor/EncryptorImplTest.java @@ -142,4 +142,4 @@ public void testEncryptionAndDecryptionWithEmptyMasterKey() { illegalStateException.getMessage()); } -} \ No newline at end of file +} diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceActionTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceActionTest.java index 3dd5c21214..2ece0eb5cd 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceActionTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceActionTest.java @@ -83,4 +83,4 @@ public void testDoExecuteWithException() { Assertions.assertEquals("Error", exception.getMessage()); } -} \ No newline at end of file +} diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceActionTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceActionTest.java index 9beeb1a9a9..61b197a805 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceActionTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceActionTest.java @@ -75,4 +75,4 @@ public void testDoExecuteWithException() { Assertions.assertEquals("Error", exception.getMessage()); } -} \ No newline at end of file +} diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceActionTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceActionTest.java index d5506c0a45..0546df643d 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceActionTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceActionTest.java @@ -134,4 +134,4 @@ public void testDoExecuteWithException() { Assertions.assertEquals("Error", exception.getMessage()); } -} \ No newline at end of file +} diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceActionTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceActionTest.java index fecab012d2..2b9305c459 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceActionTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceActionTest.java @@ -84,4 +84,4 @@ public void testDoExecuteWithException() { Assertions.assertEquals("Error", exception.getMessage()); } -} \ No newline at end of file +} diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/utils/SchedulerTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/utils/SchedulerTest.java index d091e77044..e3dac306cd 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/utils/SchedulerTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/utils/SchedulerTest.java @@ -42,4 +42,4 @@ public void testSchedule() { Assert.assertTrue(isRun.get()); } -} \ No newline at end of file +} diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java index 8a6d3b265d..cd600d856e 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java @@ -188,4 +188,3 @@ public boolean isSelectAll() { return selectAll; } } - diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/BindingTupleResultSet.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/BindingTupleResultSet.java index c3b5d2e84d..d9eb463572 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/BindingTupleResultSet.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/BindingTupleResultSet.java @@ -58,4 +58,3 @@ public static DataRows buildDataRows(List columnNodes, List hasScript(String expectedCode) { return hasFieldWithValue("script", "has script", is(new Script(expectedCode))); } } - diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java index 48e21246b2..de0c23c4e9 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java @@ -122,4 +122,3 @@ protected MLAlgoParams convertArgumentToMLParameter(Map argumen } } - diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java index 938ff60157..36834bc23a 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java @@ -109,4 +109,3 @@ protected Map processArgs(Map arguments) { return res; } } - diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/antlr/NowLikeFunctionParserTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/antlr/NowLikeFunctionParserTest.java index fb849f6de7..9f635fdd81 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/antlr/NowLikeFunctionParserTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/antlr/NowLikeFunctionParserTest.java @@ -1,74 +1,74 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - - -package org.opensearch.sql.ppl.antlr; - -import static org.junit.Assert.assertNotEquals; - -import java.util.List; -import org.antlr.v4.runtime.tree.ParseTree; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -public class NowLikeFunctionParserTest { - - private final PPLSyntaxParser parser = new PPLSyntaxParser(); - - /** - * Set parameterized values used in test. - * @param name Function name - * @param hasFsp Whether function has fsp argument - * @param hasShortcut Whether function has shortcut (call without `()`) - */ - public NowLikeFunctionParserTest(String name, Boolean hasFsp, Boolean hasShortcut) { - this.name = name; - this.hasFsp = hasFsp; - this.hasShortcut = hasShortcut; - } - - /** - * Returns function data to test. - * @return An iterable. - */ - @Parameterized.Parameters(name = "{0}") - public static Iterable functionNames() { - return List.of(new Object[][]{ - {"now", true, false}, - {"current_timestamp", true, true}, - {"localtimestamp", true, true}, - {"localtime", true, true}, - {"sysdate", true, false}, - {"curtime", true, false}, - {"current_time", true, true}, - {"curdate", false, false}, - {"current_date", false, true}, - {"utc_date", false, false}, - {"utc_time", false, false}, - {"utc_timestamp", false, false} - }); - } - - private final String name; - private final Boolean hasFsp; - private final Boolean hasShortcut; - - @Test - public void test_now_like_functions() { - for (var call : hasShortcut ? List.of(name, name + "()") : List.of(name + "()")) { - ParseTree tree = parser.parse("source=t | eval r=" + call); - assertNotEquals(null, tree); - - tree = parser.parse("search source=t | where a=" + call); - assertNotEquals(null, tree); - } - if (hasFsp) { - ParseTree tree = parser.parse("search source=t | where a=" + name + "(0)"); - assertNotEquals(null, tree); - } - } -} +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + + +package org.opensearch.sql.ppl.antlr; + +import static org.junit.Assert.assertNotEquals; + +import java.util.List; +import org.antlr.v4.runtime.tree.ParseTree; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class NowLikeFunctionParserTest { + + private final PPLSyntaxParser parser = new PPLSyntaxParser(); + + /** + * Set parameterized values used in test. + * @param name Function name + * @param hasFsp Whether function has fsp argument + * @param hasShortcut Whether function has shortcut (call without `()`) + */ + public NowLikeFunctionParserTest(String name, Boolean hasFsp, Boolean hasShortcut) { + this.name = name; + this.hasFsp = hasFsp; + this.hasShortcut = hasShortcut; + } + + /** + * Returns function data to test. + * @return An iterable. + */ + @Parameterized.Parameters(name = "{0}") + public static Iterable functionNames() { + return List.of(new Object[][]{ + {"now", true, false}, + {"current_timestamp", true, true}, + {"localtimestamp", true, true}, + {"localtime", true, true}, + {"sysdate", true, false}, + {"curtime", true, false}, + {"current_time", true, true}, + {"curdate", false, false}, + {"current_date", false, true}, + {"utc_date", false, false}, + {"utc_time", false, false}, + {"utc_timestamp", false, false} + }); + } + + private final String name; + private final Boolean hasFsp; + private final Boolean hasShortcut; + + @Test + public void test_now_like_functions() { + for (var call : hasShortcut ? List.of(name, name + "()") : List.of(name + "()")) { + ParseTree tree = parser.parse("source=t | eval r=" + call); + assertNotEquals(null, tree); + + tree = parser.parse("search source=t | where a=" + call); + assertNotEquals(null, tree); + } + if (hasFsp) { + ParseTree tree = parser.parse("search source=t | where a=" + name + "(0)"); + assertNotEquals(null, tree); + } + } +} diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java index 8ca6c5c84e..57cee7fa1d 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java @@ -324,4 +324,3 @@ public void testCanParseTimestampdiffFunction() { "SOURCE=test | eval k = TIMESTAMPDIFF(WEEK,'2003-01-02','2003-01-02')")); } } - diff --git a/prometheus/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java b/prometheus/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java index e16dc4329f..9472be7487 100644 --- a/prometheus/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java +++ b/prometheus/src/main/java/org/opensearch/sql/prometheus/client/PrometheusClientImpl.java @@ -126,4 +126,4 @@ private JSONObject readResponse(Response response) throws IOException { } -} \ No newline at end of file +} diff --git a/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/PrometheusMetricTable.java b/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/PrometheusMetricTable.java index b3b63327d0..4844e1f6db 100644 --- a/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/PrometheusMetricTable.java +++ b/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/PrometheusMetricTable.java @@ -115,4 +115,4 @@ public TableScanBuilder createScanBuilder() { return null; } } -} \ No newline at end of file +} diff --git a/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/implementor/PrometheusDefaultImplementor.java b/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/implementor/PrometheusDefaultImplementor.java index 221a70e9d6..6d426d13c8 100644 --- a/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/implementor/PrometheusDefaultImplementor.java +++ b/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/implementor/PrometheusDefaultImplementor.java @@ -135,4 +135,4 @@ private Optional getSpanExpression(List namedE } -} \ No newline at end of file +} diff --git a/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/querybuilder/StepParameterResolver.java b/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/querybuilder/StepParameterResolver.java index 54315bb792..2078950a5d 100644 --- a/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/querybuilder/StepParameterResolver.java +++ b/prometheus/src/main/java/org/opensearch/sql/prometheus/storage/querybuilder/StepParameterResolver.java @@ -60,4 +60,4 @@ private static Optional getSpanExpression( -} \ No newline at end of file +} diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/implementation/QueryExemplarsFunctionImplementationTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/implementation/QueryExemplarsFunctionImplementationTest.java index b5a52b0e8a..025e3bde06 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/implementation/QueryExemplarsFunctionImplementationTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/implementation/QueryExemplarsFunctionImplementationTest.java @@ -89,4 +89,3 @@ void testApplyArgumentsException() { } - diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/resolver/QueryExemplarsTableFunctionResolverTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/resolver/QueryExemplarsTableFunctionResolverTest.java index 1e296a80c3..3e26b46c8f 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/resolver/QueryExemplarsTableFunctionResolverTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/resolver/QueryExemplarsTableFunctionResolverTest.java @@ -72,4 +72,3 @@ void testResolve() { } } - diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/scan/QueryExemplarsFunctionTableScanOperatorTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/scan/QueryExemplarsFunctionTableScanOperatorTest.java index bd77eb8c2b..d4e31d4d1e 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/scan/QueryExemplarsFunctionTableScanOperatorTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/scan/QueryExemplarsFunctionTableScanOperatorTest.java @@ -189,4 +189,4 @@ void testClose() { prometheusQueryExemplarsRequest); queryExemplarsFunctionTableScanOperator.close(); } -} \ No newline at end of file +} diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusStorageFactoryTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusStorageFactoryTest.java index d6a934a015..41ac7ff144 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusStorageFactoryTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusStorageFactoryTest.java @@ -282,4 +282,3 @@ void createDataSourceSuccessWithHostnameRestrictions() { } } - diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/QueryExemplarsTableTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/QueryExemplarsTableTest.java index 81af30769e..19876d398d 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/QueryExemplarsTableTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/QueryExemplarsTableTest.java @@ -79,4 +79,3 @@ void testCreateScanBuilderWithQueryRangeTableFunction() { } } - diff --git a/spark/src/test/java/org/opensearch/sql/spark/utils/TestUtils.java b/spark/src/test/java/org/opensearch/sql/spark/utils/TestUtils.java index 0630a85096..b480e6d9d9 100644 --- a/spark/src/test/java/org/opensearch/sql/spark/utils/TestUtils.java +++ b/spark/src/test/java/org/opensearch/sql/spark/utils/TestUtils.java @@ -23,4 +23,3 @@ public static String getJson(String filename) throws IOException { } } -