Skip to content

Commit 9ed9529

Browse files
Merge branch 'main' into integ-datetime-diff-functions
2 parents b235550 + 1b58f7d commit 9ed9529

File tree

153 files changed

+3110
-1102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+3110
-1102
lines changed

.github/workflows/draft-release-notes-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ jobs:
1818
with:
1919
config-name: draft-release-notes-config.yml
2020
tag: (None)
21-
version: 2.4.0.0
21+
version: 3.0.0.0
2222
env:
2323
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sql-test-and-build-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
- name: Upload test reports
7171
if: ${{ always() && matrix.entry.os == 'ubuntu-latest' }}
7272
uses: actions/upload-artifact@v2
73+
continue-on-error: true
7374
with:
7475
name: test-reports
7576
path: |

.github/workflows/sql-test-workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@v3
24-
24+
2525
- name: Set up JDK ${{ matrix.java }}
2626
uses: actions/setup-java@v3
2727
with:
2828
distribution: 'temurin'
2929
java-version: ${{ matrix.java }}
30-
30+
3131
- name: Run tests
3232
id: tests
3333
run: |
@@ -68,7 +68,7 @@ jobs:
6868
./gradlew :integ-test:integTest || echo "* Integration test failed" >> report.log
6969
./gradlew :doctest:doctest || echo "* Doctest failed" >> report.log
7070
./scripts/bwctest.sh || echo "* Backward compatibility test failed" >> report.log
71-
71+
7272
- name: Verify test results
7373
run: |
7474
if [[ -e report.log ]]

.github/workflows/sql-workbench-test-and-build-workflow.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
env:
1313
PLUGIN_NAME: query-workbench-dashboards
1414
OPENSEARCH_VERSION: 'main'
15-
OPENSEARCH_PLUGIN_VERSION: 2.4.0.0
15+
OPENSEARCH_PLUGIN_VERSION: 3.0.0.0
1616

1717
jobs:
1818
build:
@@ -77,4 +77,3 @@ jobs:
7777
with:
7878
name: workbench-${{ matrix.os }}
7979
path: ../OpenSearch-Dashboards/plugins/workbench/build
80-

build.gradle

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
buildscript {
88
ext {
9-
opensearch_version = System.getProperty("opensearch.version", "2.4.0-SNAPSHOT")
10-
spring_version = "5.3.22"
11-
jackson_version = "2.14.0"
12-
jackson_databind_version = "2.14.0"
9+
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
1310
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
1411
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
1512
version_tokens = opensearch_version.tokenize('-')
@@ -69,9 +66,15 @@ plugins {
6966
id 'jacoco'
7067
}
7168

69+
// import versions defined in https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java#L94
70+
// versions https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/version.properties
71+
apply plugin: 'opensearch.java'
72+
7273
// Repository on root level is for dependencies that project code depends on. And this block must be placed after plugins{}
7374
repositories {
7475
mavenLocal()
76+
// todo. remove this when lucene 9.4.0 is released
77+
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/" }
7578
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
7679
mavenCentral() // For Elastic Libs that you can use to get started coding until open OpenSearch libs are available
7780
}
@@ -94,6 +97,8 @@ allprojects {
9497
subprojects {
9598
repositories {
9699
mavenLocal()
100+
// todo. remove this when lucene 9.4.0 is released
101+
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/" }
97102
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
98103
mavenCentral()
99104
}

core/build.gradle

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,16 @@ repositories {
3535

3636
dependencies {
3737
api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
38-
api group: 'org.springframework', name: 'spring-context', version: "${spring_version}"
39-
api group: 'org.springframework', name: 'spring-beans', version: "${spring_version}"
4038
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
4139
api group: 'com.facebook.presto', name: 'presto-matching', version: '0.240'
4240
api group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
43-
api "com.fasterxml.jackson.core:jackson-core:${jackson_version}"
44-
api "com.fasterxml.jackson.core:jackson-databind:${jackson_databind_version}"
45-
api "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}"
41+
api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
42+
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
43+
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
4644
api project(':common')
4745

4846
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
4947
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
50-
testImplementation group: 'org.springframework', name: 'spring-test', version: "${spring_version}"
5148
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.12.4'
5249
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.12.4'
5350
}

core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
package org.opensearch.sql.analysis;
88

9+
import static org.opensearch.sql.ast.dsl.AstDSL.and;
10+
import static org.opensearch.sql.ast.dsl.AstDSL.compare;
11+
import static org.opensearch.sql.expression.function.BuiltinFunctionName.GTE;
12+
import static org.opensearch.sql.expression.function.BuiltinFunctionName.LTE;
13+
914
import com.google.common.collect.ImmutableList;
1015
import com.google.common.collect.ImmutableMap;
1116
import com.google.common.collect.ImmutableSet;
@@ -22,6 +27,7 @@
2227
import org.opensearch.sql.ast.expression.AggregateFunction;
2328
import org.opensearch.sql.ast.expression.AllFields;
2429
import org.opensearch.sql.ast.expression.And;
30+
import org.opensearch.sql.ast.expression.Between;
2531
import org.opensearch.sql.ast.expression.Case;
2632
import org.opensearch.sql.ast.expression.Cast;
2733
import org.opensearch.sql.ast.expression.Compare;
@@ -229,6 +235,14 @@ public Expression visitCompare(Compare node, AnalysisContext context) {
229235
functionName, Arrays.asList(left, right));
230236
}
231237

238+
@Override
239+
public Expression visitBetween(Between node, AnalysisContext context) {
240+
return and(
241+
compare(">=", node.getValue(), node.getLowerBound()),
242+
compare("<=", node.getValue(), node.getUpperBound())
243+
).accept(this, context);
244+
}
245+
232246
@Override
233247
public Expression visitCase(Case node, AnalysisContext context) {
234248
List<WhenClause> whens = new ArrayList<>();

core/src/main/java/org/opensearch/sql/ast/AbstractNodeVisitor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.opensearch.sql.ast.expression.And;
1313
import org.opensearch.sql.ast.expression.Argument;
1414
import org.opensearch.sql.ast.expression.AttributeList;
15+
import org.opensearch.sql.ast.expression.Between;
1516
import org.opensearch.sql.ast.expression.Case;
1617
import org.opensearch.sql.ast.expression.Cast;
1718
import org.opensearch.sql.ast.expression.Compare;
@@ -173,6 +174,10 @@ public T visitCompare(Compare node, C context) {
173174
return visitChildren(node, context);
174175
}
175176

177+
public T visitBetween(Between node, C context) {
178+
return visitChildren(node, context);
179+
}
180+
176181
public T visitArgument(Argument node, C context) {
177182
return visitChildren(node, context);
178183
}

core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.opensearch.sql.ast.expression.AllFields;
1717
import org.opensearch.sql.ast.expression.And;
1818
import org.opensearch.sql.ast.expression.Argument;
19+
import org.opensearch.sql.ast.expression.Between;
1920
import org.opensearch.sql.ast.expression.Case;
2021
import org.opensearch.sql.ast.expression.Cast;
2122
import org.opensearch.sql.ast.expression.Compare;
@@ -59,6 +60,7 @@
5960
import org.opensearch.sql.ast.tree.TableFunction;
6061
import org.opensearch.sql.ast.tree.UnresolvedPlan;
6162
import org.opensearch.sql.ast.tree.Values;
63+
import org.opensearch.sql.expression.function.BuiltinFunctionName;
6264

6365
/**
6466
* Class of static methods to create specific node instances.
@@ -320,6 +322,12 @@ public static UnresolvedExpression compare(
320322
return new Compare(operator, left, right);
321323
}
322324

325+
public static UnresolvedExpression between(UnresolvedExpression value,
326+
UnresolvedExpression lowerBound,
327+
UnresolvedExpression upperBound) {
328+
return new Between(value, lowerBound, upperBound);
329+
}
330+
323331
public static Argument argument(String argName, Literal argValue) {
324332
return new Argument(argName, argValue);
325333
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.sql.ast.expression;
7+
8+
import java.util.Arrays;
9+
import java.util.List;
10+
import lombok.Data;
11+
import lombok.EqualsAndHashCode;
12+
import org.opensearch.sql.ast.AbstractNodeVisitor;
13+
import org.opensearch.sql.ast.Node;
14+
15+
/**
16+
* Unresolved expression for BETWEEN.
17+
*/
18+
@Data
19+
@EqualsAndHashCode(callSuper = false)
20+
public class Between extends UnresolvedExpression {
21+
22+
/** Value for range check. */
23+
private final UnresolvedExpression value;
24+
25+
/** Lower bound of the range (inclusive). */
26+
private final UnresolvedExpression lowerBound;
27+
28+
/** Upper bound of the range (inclusive). */
29+
private final UnresolvedExpression upperBound;
30+
31+
@Override
32+
public List<? extends Node> getChild() {
33+
return Arrays.asList(value, lowerBound, upperBound);
34+
}
35+
36+
@Override
37+
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
38+
return nodeVisitor.visitBetween(this, context);
39+
}
40+
}

core/src/main/java/org/opensearch/sql/expression/DSL.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ public static FunctionExpression minute(Expression... expressions) {
354354
return compile(FunctionProperties.None, BuiltinFunctionName.MINUTE, expressions);
355355
}
356356

357+
public static FunctionExpression minute_of_day(Expression... expressions) {
358+
return compile(FunctionProperties.None, BuiltinFunctionName.MINUTE_OF_DAY, expressions);
359+
}
360+
357361
public static FunctionExpression month(Expression... expressions) {
358362
return compile(FunctionProperties.None, BuiltinFunctionName.MONTH, expressions);
359363
}
@@ -486,6 +490,10 @@ public static FunctionExpression replace(Expression... expressions) {
486490
return compile(FunctionProperties.None, BuiltinFunctionName.REPLACE, expressions);
487491
}
488492

493+
public static FunctionExpression reverse(Expression... expressions) {
494+
return compile(FunctionProperties.None, BuiltinFunctionName.REVERSE, expressions);
495+
}
496+
489497
public static FunctionExpression and(Expression... expressions) {
490498
return compile(FunctionProperties.None, BuiltinFunctionName.AND, expressions);
491499
}
@@ -715,6 +723,10 @@ public static FunctionExpression match_bool_prefix(Expression... args) {
715723
return compile(FunctionProperties.None, BuiltinFunctionName.MATCH_BOOL_PREFIX, args);
716724
}
717725

726+
public static FunctionExpression wildcard_query(Expression... args) {
727+
return compile(FunctionProperties.None,BuiltinFunctionName.WILDCARD_QUERY, args);
728+
}
729+
718730
public static FunctionExpression now(FunctionProperties functionProperties,
719731
Expression... args) {
720732
return compile(functionProperties, BuiltinFunctionName.NOW, args);
@@ -760,6 +772,22 @@ public static FunctionExpression current_date(FunctionProperties functionPropert
760772
return compile(functionProperties, BuiltinFunctionName.CURRENT_DATE, args);
761773
}
762774

775+
public static FunctionExpression utc_date(FunctionProperties functionProperties,
776+
Expression... args) {
777+
return compile(functionProperties, BuiltinFunctionName.UTC_DATE, args);
778+
}
779+
780+
public static FunctionExpression utc_time(FunctionProperties functionProperties,
781+
Expression... args) {
782+
return compile(functionProperties, BuiltinFunctionName.UTC_TIME, args);
783+
}
784+
785+
public static FunctionExpression utc_timestamp(FunctionProperties functionProperties,
786+
Expression... args) {
787+
return compile(functionProperties, BuiltinFunctionName.UTC_TIMESTAMP, args);
788+
789+
}
790+
763791
@SuppressWarnings("unchecked")
764792
private static <T extends FunctionImplementation>
765793
T compile(FunctionProperties functionProperties,

0 commit comments

Comments
 (0)