Skip to content

Commit

Permalink
Merge branch 'main' into integ-datetime-addsubtime-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury-Fridlyand authored Jan 6, 2023
2 parents b2a46f9 + b919ba0 commit 3c77a95
Show file tree
Hide file tree
Showing 164 changed files with 3,864 additions and 1,148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/draft-release-notes-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
with:
config-name: draft-release-notes-config.yml
tag: (None)
version: 2.4.0.0
version: 3.0.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/sql-test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
- name: Upload test reports
if: ${{ always() && matrix.entry.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v2
continue-on-error: true
with:
name: test-reports
path: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sql-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}

- name: Run tests
id: tests
run: |
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
./gradlew :integ-test:integTest || echo "* Integration test failed" >> report.log
./gradlew :doctest:doctest || echo "* Doctest failed" >> report.log
./scripts/bwctest.sh || echo "* Backward compatibility test failed" >> report.log
- name: Verify test results
run: |
if [[ -e report.log ]]
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/sql-workbench-test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
PLUGIN_NAME: query-workbench-dashboards
OPENSEARCH_VERSION: 'main'
OPENSEARCH_PLUGIN_VERSION: 2.4.0.0
OPENSEARCH_PLUGIN_VERSION: 3.0.0.0

jobs:
build:
Expand Down Expand Up @@ -77,4 +77,3 @@ jobs:
with:
name: workbench-${{ matrix.os }}
path: ../OpenSearch-Dashboards/plugins/workbench/build

26 changes: 14 additions & 12 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# OpenSearch SQL Maintainers
## Overview

## Maintainers
This document contains a list of maintainers in this repo. See [opensearch-project/.github/RESPONSIBILITIES.md](https://github.com/opensearch-project/.github/blob/main/RESPONSIBILITIES.md#maintainer-responsibilities) that explains what the role of maintainer means, what maintainers do in this and other repos, and how they should be doing it. If you're interested in contributing, and becoming a maintainer, see [CONTRIBUTING](CONTRIBUTING.md).

| Maintainer | GitHub ID | Affiliation |
| --------------- | --------- | ----------- |
| Anirudha (Ani) Jadhav | [anirudha](https://github.com/anirudha) | Amazon |
| Peng Huo | [penghuo](https://github.com/penghuo) | Amazon |
| Chen Dai | [dai-chen](https://github.com/dai-chen) | Amazon |
| Chloe Zhang | [chloe-zh](https://github.com/chloe-zh) | Amazon |
| Nick Knize | [nknize](https://github.com/nknize) | Amazon |
| Charlotte Henkle | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
| Max Ksyunz | [MaxKsyunz](https://github.com/MaxKsyunz) | BitQuill |
| Yury Fridlyand | [Yury-Fridlyand](https://github.com/Yury-Fridlyand) | BitQuill |
## Current Maintainers

| Maintainer | GitHub ID | Affiliation |
| --------------------- | --------------------------------------------------- | ----------- |
| Anirudha (Ani) Jadhav | [anirudha](https://github.com/anirudha) | Amazon |
| Peng Huo | [penghuo](https://github.com/penghuo) | Amazon |
| Chen Dai | [dai-chen](https://github.com/dai-chen) | Amazon |
| Chloe Zhang | [chloe-zh](https://github.com/chloe-zh) | Amazon |
| Nick Knize | [nknize](https://github.com/nknize) | Amazon |
| Charlotte Henkle | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
| Max Ksyunz | [MaxKsyunz](https://github.com/MaxKsyunz) | BitQuill |
| Yury Fridlyand | [Yury-Fridlyand](https://github.com/Yury-Fridlyand) | BitQuill |
13 changes: 9 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "2.4.0-SNAPSHOT")
spring_version = "5.3.22"
jackson_version = "2.14.0"
jackson_databind_version = "2.14.0"
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
Expand Down Expand Up @@ -69,9 +66,15 @@ plugins {
id 'jacoco'
}

// import versions defined in https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java#L94
// versions https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/version.properties
apply plugin: 'opensearch.java'

// Repository on root level is for dependencies that project code depends on. And this block must be placed after plugins{}
repositories {
mavenLocal()
// todo. remove this when lucene 9.4.0 is released
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral() // For Elastic Libs that you can use to get started coding until open OpenSearch libs are available
}
Expand All @@ -94,6 +97,8 @@ allprojects {
subprojects {
repositories {
mavenLocal()
// todo. remove this when lucene 9.4.0 is released
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
}
Expand Down
9 changes: 3 additions & 6 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,16 @@ repositories {

dependencies {
api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
api group: 'org.springframework', name: 'spring-context', version: "${spring_version}"
api group: 'org.springframework', name: 'spring-beans', version: "${spring_version}"
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
api group: 'com.facebook.presto', name: 'presto-matching', version: '0.240'
api group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
api "com.fasterxml.jackson.core:jackson-core:${jackson_version}"
api "com.fasterxml.jackson.core:jackson-databind:${jackson_databind_version}"
api "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}"
api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
api project(':common')

testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testImplementation group: 'org.springframework', name: 'spring-test', version: "${spring_version}"
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.12.4'
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.12.4'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

package org.opensearch.sql.analysis;

import static org.opensearch.sql.ast.dsl.AstDSL.and;
import static org.opensearch.sql.ast.dsl.AstDSL.compare;
import static org.opensearch.sql.expression.function.BuiltinFunctionName.GTE;
import static org.opensearch.sql.expression.function.BuiltinFunctionName.LTE;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand All @@ -22,6 +27,7 @@
import org.opensearch.sql.ast.expression.AggregateFunction;
import org.opensearch.sql.ast.expression.AllFields;
import org.opensearch.sql.ast.expression.And;
import org.opensearch.sql.ast.expression.Between;
import org.opensearch.sql.ast.expression.Case;
import org.opensearch.sql.ast.expression.Cast;
import org.opensearch.sql.ast.expression.Compare;
Expand Down Expand Up @@ -229,6 +235,14 @@ public Expression visitCompare(Compare node, AnalysisContext context) {
functionName, Arrays.asList(left, right));
}

@Override
public Expression visitBetween(Between node, AnalysisContext context) {
return and(
compare(">=", node.getValue(), node.getLowerBound()),
compare("<=", node.getValue(), node.getUpperBound())
).accept(this, context);
}

@Override
public Expression visitCase(Case node, AnalysisContext context) {
List<WhenClause> whens = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.opensearch.sql.ast.expression.And;
import org.opensearch.sql.ast.expression.Argument;
import org.opensearch.sql.ast.expression.AttributeList;
import org.opensearch.sql.ast.expression.Between;
import org.opensearch.sql.ast.expression.Case;
import org.opensearch.sql.ast.expression.Cast;
import org.opensearch.sql.ast.expression.Compare;
Expand Down Expand Up @@ -173,6 +174,10 @@ public T visitCompare(Compare node, C context) {
return visitChildren(node, context);
}

public T visitBetween(Between node, C context) {
return visitChildren(node, context);
}

public T visitArgument(Argument node, C context) {
return visitChildren(node, context);
}
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.opensearch.sql.ast.expression.AllFields;
import org.opensearch.sql.ast.expression.And;
import org.opensearch.sql.ast.expression.Argument;
import org.opensearch.sql.ast.expression.Between;
import org.opensearch.sql.ast.expression.Case;
import org.opensearch.sql.ast.expression.Cast;
import org.opensearch.sql.ast.expression.Compare;
Expand Down Expand Up @@ -59,6 +60,7 @@
import org.opensearch.sql.ast.tree.TableFunction;
import org.opensearch.sql.ast.tree.UnresolvedPlan;
import org.opensearch.sql.ast.tree.Values;
import org.opensearch.sql.expression.function.BuiltinFunctionName;

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

public static UnresolvedExpression between(UnresolvedExpression value,
UnresolvedExpression lowerBound,
UnresolvedExpression upperBound) {
return new Between(value, lowerBound, upperBound);
}

public static Argument argument(String argName, Literal argValue) {
return new Argument(argName, argValue);
}
Expand Down
40 changes: 40 additions & 0 deletions core/src/main/java/org/opensearch/sql/ast/expression/Between.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.sql.ast.expression;

import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.opensearch.sql.ast.AbstractNodeVisitor;
import org.opensearch.sql.ast.Node;

/**
* Unresolved expression for BETWEEN.
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class Between extends UnresolvedExpression {

/** Value for range check. */
private final UnresolvedExpression value;

/** Lower bound of the range (inclusive). */
private final UnresolvedExpression lowerBound;

/** Upper bound of the range (inclusive). */
private final UnresolvedExpression upperBound;

@Override
public List<? extends Node> getChild() {
return Arrays.asList(value, lowerBound, upperBound);
}

@Override
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
return nodeVisitor.visitBetween(this, context);
}
}
28 changes: 28 additions & 0 deletions core/src/main/java/org/opensearch/sql/expression/DSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ public static FunctionExpression minute(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MINUTE, expressions);
}

public static FunctionExpression minute_of_day(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MINUTE_OF_DAY, expressions);
}

public static FunctionExpression month(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.MONTH, expressions);
}
Expand Down Expand Up @@ -486,6 +490,10 @@ public static FunctionExpression replace(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.REPLACE, expressions);
}

public static FunctionExpression reverse(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.REVERSE, expressions);
}

public static FunctionExpression and(Expression... expressions) {
return compile(FunctionProperties.None, BuiltinFunctionName.AND, expressions);
}
Expand Down Expand Up @@ -715,6 +723,10 @@ public static FunctionExpression match_bool_prefix(Expression... args) {
return compile(FunctionProperties.None, BuiltinFunctionName.MATCH_BOOL_PREFIX, args);
}

public static FunctionExpression wildcard_query(Expression... args) {
return compile(FunctionProperties.None,BuiltinFunctionName.WILDCARD_QUERY, args);
}

public static FunctionExpression now(FunctionProperties functionProperties,
Expression... args) {
return compile(functionProperties, BuiltinFunctionName.NOW, args);
Expand Down Expand Up @@ -760,6 +772,22 @@ public static FunctionExpression current_date(FunctionProperties functionPropert
return compile(functionProperties, BuiltinFunctionName.CURRENT_DATE, args);
}

public static FunctionExpression utc_date(FunctionProperties functionProperties,
Expression... args) {
return compile(functionProperties, BuiltinFunctionName.UTC_DATE, args);
}

public static FunctionExpression utc_time(FunctionProperties functionProperties,
Expression... args) {
return compile(functionProperties, BuiltinFunctionName.UTC_TIME, args);
}

public static FunctionExpression utc_timestamp(FunctionProperties functionProperties,
Expression... args) {
return compile(functionProperties, BuiltinFunctionName.UTC_TIMESTAMP, args);

}

@SuppressWarnings("unchecked")
private static <T extends FunctionImplementation>
T compile(FunctionProperties functionProperties,
Expand Down
Loading

0 comments on commit 3c77a95

Please sign in to comment.