Skip to content

Commit

Permalink
Update JDBC driver version (opensearch-project#941)
Browse files Browse the repository at this point in the history
* Bumped the JDBC driver version to 2.0.0.0

Signed-off-by: Guian Gumpac <[email protected]>

* Added a test to ensure versions match in the jar file and debug messages

Signed-off-by: Guian Gumpac <[email protected]>

Signed-off-by: Guian Gumpac <[email protected]>
  • Loading branch information
Guian Gumpac authored and penghuo committed Oct 21, 2022
1 parent 1f2e881 commit 1a48c37
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/org/opensearch/sql/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ public LogicalPlan visitAD(AD node, AnalysisContext context) {
currentEnv.define(new Symbol(Namespace.FIELD_NAME, RCF_ANOMALOUS), ExprCoreType.BOOLEAN);
} else {
currentEnv.define(new Symbol(Namespace.FIELD_NAME, RCF_ANOMALY_GRADE), ExprCoreType.DOUBLE);
currentEnv.define(new Symbol(Namespace.FIELD_NAME, RCF_TIMESTAMP), ExprCoreType.TIMESTAMP);
currentEnv.define(new Symbol(Namespace.FIELD_NAME,
(String) node.getArguments().get(TIME_FIELD).getValue()), ExprCoreType.TIMESTAMP);
}
return new LogicalAD(child, options);
}
Expand Down
18 changes: 17 additions & 1 deletion core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import static org.opensearch.sql.data.type.ExprCoreType.LONG;
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 com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -998,5 +999,20 @@ public void table_function_with_wrong_table_function() {
assertEquals("unsupported function name: queryrange", exception.getMessage());
}


@Test
public void pr_919() {
Map<String, Literal> argumentMap =
new HashMap<>() {
{
put("anomaly_grade", AstDSL.doubleLiteral(1.0));
put("time_field", AstDSL.stringLiteral("timestamp_value"));
}
};
assertAnalyzeEqual(
LogicalPlanDSL.project(
new LogicalAD(LogicalPlanDSL.relation("schema", table), argumentMap),
DSL.named("timestamp_value", DSL.ref("timestamp_value", TIMESTAMP))),
AstDSL.project(
new AD(AstDSL.relation("schema"), argumentMap), AstDSL.field("timestamp_value")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class TestConfig {
.put(STRING_TYPE_MISSING_VALUE_FIELD, ExprCoreType.STRING)
.put("struct_value", ExprCoreType.STRUCT)
.put("array_value", ExprCoreType.ARRAY)
.put("timestamp_value", ExprCoreType.TIMESTAMP)
.build();

@Bean
Expand Down
3 changes: 2 additions & 1 deletion sql-jdbc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
group 'org.opensearch.client'

// keep version in sync with version in Driver source
version '1.1.0.1'
version '2.0.0.0'

boolean snapshot = "true".equals(System.getProperty("build.snapshot", "false"));
if (snapshot) {
Expand Down Expand Up @@ -98,6 +98,7 @@ shadowJar {
}

test {
systemProperty("opensearch_jdbc_version", version);
useJUnitPlatform()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public Logger getLog() {
}

private String getUserAgent() {
return String.format("openes-jdbc/%s (Java %s)",
return String.format("opensearch-jdbc/%s (Java %s)",
Version.Current.getFullVersion(), JavaUtil.getJavaVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

public enum Version {

// keep this in sync with the gradle version
Current(1, 0, 0, 0);
// keep this in sync with the sql-jdbc/build.gradle file
Current(2, 0, 0, 0);

private int major;
private int minor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import org.junit.jupiter.api.Test;
import org.opensearch.jdbc.internal.Version;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class VersionMatchTest {

@Test
void testVersionMatchesBuildGradleVersion() {
assertEquals(Version.Current.getFullVersion(), System.getProperty("opensearch_jdbc_version"));
}
}

0 comments on commit 1a48c37

Please sign in to comment.