Skip to content

Merge 2.x to main after 2.4 release #1063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 178 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
6a60d0b
Add release notes for 2.2.0.0 (#730) (#731)
opensearch-trigger-bot[bot] Aug 6, 2022
7a4145e
Backport Spring and jackson-databind version bump to 2.x (#759)
dai-chen Aug 16, 2022
dabe1d7
Replace 2x `LogUtils` by `QueryContext` (#747) (#753)
opensearch-trigger-bot[bot] Aug 17, 2022
8729c32
Merge branch 'main' into 2.x
joshuali925 Aug 17, 2022
8185127
Resolve conflicts
joshuali925 Aug 17, 2022
bc16f20
Update snapshots for jest tests on workbench (#740) (#761)
opensearch-trigger-bot[bot] Aug 17, 2022
9819635
Merge main to 2.x branch (#771)
joshuali925 Aug 17, 2022
e9d5b9a
Bump Checkstyle version to latest (#767) (#776)
opensearch-trigger-bot[bot] Aug 17, 2022
581e3c8
Change master node timeout to new API (#793) (#797)
opensearch-trigger-bot[bot] Sep 7, 2022
7fb91c7
Merge branch 'main' into 2.x
penghuo Sep 14, 2022
7bb52a8
Merge pull request #830 from penghuo/backport/2.x
penghuo Sep 14, 2022
929ebfe
Bump version to 2.4 (#832)
penghuo Sep 14, 2022
1bd0f35
Change ApplicationContext lifecycle to per node level (#822)
penghuo Sep 15, 2022
acb9fcc
Reorganize GitHub workflows. (#118)
Yury-Fridlyand Sep 16, 2022
fa8d5bd
Fix EqualsAndHashCode annotation warning messages. (#847)
GabeFernandez310 Sep 20, 2022
213b6ae
Add low-level create table and table exists API (#834)
dai-chen Sep 21, 2022
921791b
Add new test workflow. (#119)
Yury-Fridlyand Sep 23, 2022
e28ac78
Add implementation of `now`, `sysdate`, `localtime` and similar funct…
Yury-Fridlyand Sep 23, 2022
705ad13
Update com.fasterxml.jackson to 2.13.4 to match opensearch repo.
Sep 26, 2022
8245943
Merge pull request #858 from Bit-Quill/integ-jackson-2.13.4
Yury-Fridlyand Sep 26, 2022
e04d6f8
Add datetime functions `FROM_UNIXTIME` and `UNIX_TIMESTAMP` (#835)
Yury-Fridlyand Sep 27, 2022
489f2ad
Typo fix.
Yury-Fridlyand Sep 27, 2022
63c5137
Address PR feedback.
Yury-Fridlyand Sep 27, 2022
10e44ee
Merge pull request #837 from Bit-Quill/integ-reorganize-workflows
Yury-Fridlyand Sep 28, 2022
3ca6450
Adding `CONVERT_TZ` and `DATETIME` functions to SQL and PPL (#848)
MitchellGale Sep 28, 2022
9210c5f
Remove duplicated png file (#865)
joshuali925 Sep 29, 2022
91abe43
Update jetty dependency, wiremock dependency, and fix associated comp…
forestmvey Sep 29, 2022
5aef2e6
Trigger build on pull request synchronize
vamsimanohar Sep 29, 2022
7b1574e
Add patterns and grok command (#813)
joshuali925 Sep 30, 2022
057fa44
Fix NPE with multiple queries containing DOT(.) in index name. (#870)
vamsimanohar Sep 30, 2022
b244f2e
Fix indentation of patterns example (#880)
joshuali925 Oct 3, 2022
c04c784
Prometheus Connector Initial Code
vamsimanohar Sep 30, 2022
cb1b20c
Restricted catalog name to [a-zA-Z0-9_-] characters
vamsimanohar Sep 30, 2022
46aa656
Update docs - missing changes for #754. (#884)
Yury-Fridlyand Oct 11, 2022
c3840b6
Adding highlight support in PPL with optional arguments and wildcard …
forestmvey Oct 11, 2022
526b973
Fix workflow and add `name` option.
Yury-Fridlyand Oct 12, 2022
2661232
initial commit for sql workbench windows and macos
derek-ho Oct 12, 2022
7a1c7ae
name files
derek-ho Oct 12, 2022
a8553f7
add groupId to pluginzip publication (#906)
penghuo Oct 12, 2022
b30d156
Update group to groupId (#908)
penghuo Oct 12, 2022
124a5c6
Fix broken links.
Yury-Fridlyand Oct 13, 2022
ef535e9
clean up code with matrix
derek-ho Oct 13, 2022
8a58eb9
forgot comma
derek-ho Oct 13, 2022
828101c
use cross env for windows and enable windows and macos ci in sql
derek-ho Oct 13, 2022
53ef534
disable integration and jacoco for windows and mac
derek-ho Oct 13, 2022
7569d6d
add gitattributes file to normalize line endings
derek-ho Oct 13, 2022
912731b
move gitattributes into appropriate folder
derek-ho Oct 13, 2022
6a6cfd6
configure line endings for windows
derek-ho Oct 13, 2022
0d016ef
fix one test file and get rid of git attributes
derek-ho Oct 14, 2022
a8709d2
disable doctest and integ test
derek-ho Oct 14, 2022
d4c9f1e
fix up tests
derek-ho Oct 17, 2022
9df2acd
fix tests and add java docs
derek-ho Oct 17, 2022
8f98fa4
revert error format
derek-ho Oct 17, 2022
7a39dcb
revert pretty format response
derek-ho Oct 17, 2022
bd8572a
revert error formatter test file
derek-ho Oct 17, 2022
a2b473b
replace carriage return with nothing
derek-ho Oct 18, 2022
a3747a3
remove windows git config
derek-ho Oct 18, 2022
4b50a01
Merge pull request #911 from Bit-Quill/fix-old-broken-links
Yury-Fridlyand Oct 18, 2022
fec1a0c
Update SQL CLI to use AWS session token. (#918)
Yury-Fridlyand Oct 19, 2022
e70df11
fix PR comments and fail test on purpose to see if upload test report…
derek-ho Oct 19, 2022
de65184
fix matrix entry
derek-ho Oct 19, 2022
a6f3ceb
remove test failure
derek-ho Oct 19, 2022
863f751
Table Function Initial Setup.
vamsimanohar Sep 30, 2022
3f372bb
fix up to run on right os
derek-ho Oct 20, 2022
5e24f3c
fix up indentation
derek-ho Oct 20, 2022
2c65ecb
Update version of `jackson-databind` for `sql-jdbc` only (#943)
Oct 20, 2022
9debb01
Add security policy for ml-commons library (#945)
joshuali925 Oct 20, 2022
3fbe3e4
remove env. build_args to make it cleaner
derek-ho Oct 20, 2022
1f2e881
Add `typeof` function. (#867)
Yury-Fridlyand Oct 20, 2022
05d53e7
Update JDBC driver version (#941)
Oct 20, 2022
954c072
try removing env var
derek-ho Oct 20, 2022
79f765c
remove unecessary import
derek-ho Oct 20, 2022
c137ac3
Merge branch '2.x' into feature/maximus-m1
dai-chen Oct 21, 2022
3a9d217
Add missing API method in prometheus table
dai-chen Oct 21, 2022
30a2d27
Fix result order of parse with other run time fields (#934)
joshuali925 Oct 22, 2022
bfad32c
SHOW Catalogs Implementation
vamsimanohar Oct 18, 2022
0699baa
Merge pull request #907 from derek-ho/enable-windows-macos
derek-ho Oct 25, 2022
66dc7b7
change condition to upload coverage for workbench
derek-ho Oct 25, 2022
f9e8e1f
Merge pull request #967 from derek-ho/always-upload-coverage
derek-ho Oct 25, 2022
2a16227
Add category_field to AD command in PPL (#952)
joshuali925 Oct 26, 2022
cacdb1b
Adding docs related to prometheus and catalog functionalities.
vamsimanohar Oct 25, 2022
eb08f57
AD timefield name issue (#919)
jngz-es Oct 27, 2022
f011f0d
Bump ansi-regex for workbench (#975)
joshuali925 Oct 27, 2022
5c7b22a
Merge branch '2.x' into feature/maximus-m1
penghuo Oct 27, 2022
ccc2230
Merge pull request #904 from Bit-Quill/fix-manual-workflow
Yury-Fridlyand Oct 27, 2022
ba97742
Removed json-smart (#978)
Oct 27, 2022
91baab1
Add time window and window assigner (#950)
dai-chen Oct 27, 2022
f37736f
Add take() aggregation function in PPL (#949)
joshuali925 Oct 27, 2022
b286742
add table default impl of exist and create
penghuo Oct 27, 2022
2016d5c
Merge pull request #979 from penghuo/hp/feature/maximus-m1/merge
penghuo Oct 27, 2022
b843639
SHOW CATALOGS documentation and integ tests (#977)
vamsimanohar Oct 27, 2022
63f3449
Add metadatalog interface and default in memory implementation (#974)
penghuo Oct 28, 2022
d46b389
Add functions `PERIOD_ADD` and `PERIOD_DIFF`. (#933)
Yury-Fridlyand Oct 28, 2022
3fd53ca
Enable ignored and disabled tests (#926)
Oct 28, 2022
89b3e1a
Rework on error reporting to make it more verbose and human-friendly.…
Yury-Fridlyand Sep 17, 2022
e3fe086
List tables/metrics using information_schema in source command. (#914)
vamsimanohar Oct 28, 2022
99cebe3
Update MacOS version to supported level. Updated suitable dependencie…
forestmvey Oct 28, 2022
30fcd79
Add Statement, QueryExecution and QueryManager (#845)
penghuo Oct 28, 2022
634e2ff
Update Jackson Databind version to 2.13.4.2 (#148) (#992)
margarit-h Oct 31, 2022
c6b234c
A Generic ML Command in PPL (#971)
jngz-es Oct 31, 2022
7b6a1e2
Add Streaming Source Impl
penghuo Nov 1, 2022
3231dfe
update build.gradle
penghuo Nov 1, 2022
40d8d9f
Describe Table with catalog name. (#989)
vamsimanohar Nov 1, 2022
c230532
Included Authenticators (#988)
vamsimanohar Nov 1, 2022
21373b9
Merge pull request #839 from Bit-Quill/integ-improve-error-reporting
Yury-Fridlyand Nov 1, 2022
e8f3205
Add watermark generator (#959)
dai-chen Nov 1, 2022
73787b7
Add stream context and window trigger (#958)
dai-chen Nov 1, 2022
4e418c7
Add document for ml command. (#1001)
jngz-es Nov 3, 2022
2938890
Add function name as identifier in antlr (#1015)
penghuo Nov 3, 2022
1a52511
Disable loading `ML-commons` plugin for doctests and corresponding te…
Yury-Fridlyand Nov 3, 2022
be4512e
Prometheus select metric and stats queries. (#956)
vamsimanohar Nov 3, 2022
752168f
change to hadoop-fs
penghuo Nov 3, 2022
91ef9b3
exclude FileSystemStreamSource from jacoco
penghuo Nov 3, 2022
4282450
Fix incorrect results returned by `min`, `max` and `avg` (#1000)
Yury-Fridlyand Nov 3, 2022
b76c8f2
Bump sql-cli version to 1.1.0 (#1023)
penghuo Nov 3, 2022
5fc1eb5
exclude unnecessary depedency
penghuo Nov 3, 2022
c8b0118
Update integ-test depedency
penghuo Nov 4, 2022
b56edc7
Add release note (#1033) (#1034)
opensearch-trigger-bot[bot] Nov 4, 2022
fbd6c7a
Merge branch '2.x' into merge-2.x-after-release
dai-chen Nov 4, 2022
0a4d92d
Fix `FLOAT` -> `DOUBLE` cast. (#1025)
Yury-Fridlyand Nov 7, 2022
eea2689
Merge pull request #1039 from dai-chen/merge-2.x-after-release
penghuo Nov 7, 2022
315c39a
Merge branch 'feature/maximus-m1' into hp/feature/maximus/streamingso…
penghuo Nov 7, 2022
a4c7cf7
Fix error messaging from prometheus. (#1029) (#1037)
opensearch-trigger-bot[bot] Nov 7, 2022
f8c58f1
Add `query` function as alternate syntax to `query_string` function (…
GabeFernandez310 Nov 7, 2022
40535d7
Add micro batch streaming execution
penghuo Nov 8, 2022
48eeb0e
Deprecate span collector (#990)
dai-chen Nov 8, 2022
8c91689
Update DATE and TIME functions to parse string input as datetime (#991)
MitchellGale Nov 8, 2022
5105022
Add Streaming source impl (#994)
penghuo Nov 8, 2022
4eadb28
Merge branch 'feature/maximus-m1' into hp/feature/maximus/microbatchtask
penghuo Nov 8, 2022
2ec975a
back quote fix (#1041) (#1050)
opensearch-trigger-bot[bot] Nov 8, 2022
c2ccc91
Catalog to Datasource changes (#1027) (#1049)
vamsimanohar Nov 8, 2022
d63345b
fix compile issue
penghuo Nov 9, 2022
d908770
Bump jackson to 2.14.0 (#1058)
joshuali925 Nov 9, 2022
edce878
Merge pull request #1060 from opensearch-project/backport/backport-10…
Yury-Fridlyand Nov 9, 2022
6aee254
add PlanContext
penghuo Nov 9, 2022
5b99c08
bump jackson version
penghuo Nov 9, 2022
03f30e3
Add valueOf() to Expression (#1055)
joshuali925 Nov 9, 2022
05be949
Merge branch '2.x' into hp/main/2.4merge
penghuo Nov 9, 2022
ee0fdc8
resolve conflict version
penghuo Nov 9, 2022
3c6b37a
Merge 2.x to Maximus feature branch (#1062)
dai-chen Nov 9, 2022
75c2194
Merge branch 'feature/maximus-m1' into hp/feature/maximus/microbatchtask
penghuo Nov 12, 2022
faff812
fix bug
penghuo Nov 12, 2022
b0cca57
Merge pull request #1044 from penghuo/hp/feature/maximus/microbatchtask
penghuo Nov 14, 2022
662a938
Integ tests fix for arm64.[Failure in starting up prometheus server] …
vamsimanohar Nov 14, 2022
7f107a4
Merge branch '2.x' into feature/maximus/2.x
penghuo Nov 16, 2022
0504c71
Merge pull request #1078 from penghuo/feature/maximus/2.x
penghuo Nov 16, 2022
cdb30ee
add junit to resolutions for CVE-2020-15250 (#1079)
rupal-bq Nov 17, 2022
81c9285
Decouple function repository and DSL from IoC container for use anywh…
dai-chen Nov 17, 2022
fef20f8
Catalog to Datasource changes (#1086)
vamsimanohar Nov 18, 2022
e280866
Move DataSourceServiceImpl to core module (#1084)
penghuo Nov 18, 2022
d4d289c
Add CBRT to the V2 engine (#1081)
margarit-h Nov 21, 2022
c6465c1
Merge branch '2.x' into hp/main/2.4merge
penghuo Nov 21, 2022
ef1d0d7
bump jackson version to 2.14.0
penghuo Nov 22, 2022
0f5d628
CVE-2020-15250 fix (#1095)
vamsimanohar Nov 22, 2022
42143b9
Add Streaming Plan Impl (#1068)
penghuo Nov 23, 2022
334cd46
Fix history file usage in SQL CLI tool. (#1077)
Yury-Fridlyand Nov 23, 2022
cfb2650
Add timeout option to SQL CLI tool. (#1076)
Yury-Fridlyand Nov 23, 2022
50669eb
Support opensearch-sql:run and update developer_guide doc (#1099)
penghuo Nov 25, 2022
34be98d
CVE-2022-45868 fix (#1107)
vamsimanohar Nov 25, 2022
06b8a29
Add Support For Legacy Syntax For Match Function In New Engine (#1090)
GabeFernandez310 Nov 28, 2022
e2bf254
Add cbrt function to the PPL (#1097)
margarit-h Nov 28, 2022
1287e89
Add MatchPhraseQuery As Alternate Syntax for Match_Phrase Function (#…
GabeFernandez310 Dec 1, 2022
43ceda1
Use query execution start time as the value of now-like functions. (#…
Dec 2, 2022
b304ddc
Add Day_Of_Year Function To OpenSearch (#1128)
GabeFernandez310 Dec 6, 2022
8ed26e6
Add Week_Of_Year Function To OpenSearch (#1127)
GabeFernandez310 Dec 6, 2022
9ec1cc1
Add Month_Of_Year Function To OpenSearch (#1129)
GabeFernandez310 Dec 6, 2022
b76a178
Add Support for Alternate Legacy MULTIMATCH syntax (#1102)
forestmvey Dec 6, 2022
354e843
Add position() function to V2 engine (#1121)
margarit-h Dec 6, 2022
6e5610c
upgrad jackson
penghuo Dec 6, 2022
1d18620
upgrade bwc baseVersion to 2.5.0
penghuo Dec 6, 2022
f530770
Add position() string function to PPL (#1147)
margarit-h Dec 7, 2022
64a3794
Improve pushdown optimization and logical to physical transformation …
dai-chen Dec 7, 2022
2af7321
Add support for wildcard_query function to the new engine (#156) (#1108)
Dec 7, 2022
c923e80
Add reverse() string function to V2 SQL Engine(#1154)
margarit-h Dec 9, 2022
c5e8fc0
Update Jackson to 2.14.1 and fix dependency resolution issues (#1150)
reta Dec 9, 2022
f8fbef7
Change LIKE operator case-insensitive match (#1160)
penghuo Dec 12, 2022
32ad2ff
Increment version to 2.5.0-SNAPSHOT (#999)
opensearch-trigger-bot[bot] Dec 13, 2022
7f377da
Merge branch '2.x' into hp/main/2.4merge
penghuo Dec 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 6 additions & 5 deletions .github/workflows/sql-odbc-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ env:
CI_OUTPUT_PATH: "sql-odbc/ci-output"
ODBC_LIB_PATH: "./build/odbc/lib"
ODBC_BIN_PATH: "./build/odbc/bin"
ODBC_BUILD_PATH: "./build/odbc/build"
AWS_SDK_INSTALL_PATH: "./build/aws-sdk/install"
ODBC_BUILD_PATH: "./build/odbc/cmake"
VCPKG_X64_INSTALL_PATH: ".\\src\\vcpkg_installed\\x64-windows"
VCPKG_X86_INSTALL_PATH: ".\\src\\vcpkg_installed\\x86-windows"

# Tests are disabled (commented out) in all jobs because they are fail and/or outdated
# Keeping them for the brighten future when we can re-activate them
jobs:
build-mac:
runs-on: macos-10.15
runs-on: macos-12
defaults:
run:
working-directory: sql-odbc
Expand Down Expand Up @@ -103,7 +104,7 @@ jobs:
- name: build-installer
if: success()
run: |
.\scripts\build_installer.ps1 Release Win32 .\src $Env:ODBC_BUILD_PATH $Env:AWS_SDK_INSTALL_PATH
.\scripts\build_installer.ps1 Release Win32 .\src $Env:ODBC_BUILD_PATH $Env:VCPKG_X86_INSTALL_PATH
#- name: test
# run: |
# cp .\\libraries\\VisualLeakDetector\\bin32\\*.* .\\bin32\\Release
Expand Down Expand Up @@ -148,7 +149,7 @@ jobs:
- name: build-installer
if: success()
run: |
.\scripts\build_installer.ps1 Release x64 .\src $Env:ODBC_BUILD_PATH $Env:AWS_SDK_INSTALL_PATH
.\scripts\build_installer.ps1 Release x64 .\src $Env:ODBC_BUILD_PATH $Env:VCPKG_X64_INSTALL_PATH
#- name: test
# run: |
# cp .\\libraries\\VisualLeakDetector\\bin64\\*.* .\\bin64\\Release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sql-test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
matrix:
entry:
- { os: ubuntu-latest, java: 11 }
- { os: windows-latest, java: 11, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc}
- { os: windows-latest, java: 11, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc -PbuildPlatform=windows }
- { os: macos-latest, java: 11, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc }
- { os: ubuntu-latest, java: 17 }
- { os: windows-latest, java: 17, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc }
- { os: windows-latest, java: 17, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc -PbuildPlatform=windows }
- { os: macos-latest, java: 17, os_build_args: -x doctest -x integTest -x jacocoTestReport -x compileJdbc }
runs-on: ${{ matrix.entry.os }}

Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/sql-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: SQL Plugin Tests

on:
workflow_dispatch:
inputs:
name:
required: false
type: string

run-name:
${{ inputs.name == '' && format('{0} @ {1}', github.ref_name, github.sha) || inputs.name }}

jobs:
build:
Expand Down Expand Up @@ -64,10 +71,10 @@ jobs:

- name: Verify test results
run: |
if [[ -e failures.log ]]
if [[ -e report.log ]]
then
echo "## FAILED TESTS :facepalm::warning::bangbang:" >> $GITHUB_STEP_SUMMARY
cat failures.log >> $GITHUB_STEP_SUMMARY
cat report.log >> $GITHUB_STEP_SUMMARY
exit 1
fi

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

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ gen
.DS_Store

/artifacts/
/.pid.lock
/.prom.pid.lock

.java-version
4 changes: 4 additions & 0 deletions DEVELOPER_GUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ The plugin codebase is in standard layout of Gradle project::
├── core
├── doctest
├── opensearch
├── filesystem
├── prometheus
├── integ-test
├── legacy
├── plugin
Expand All @@ -159,6 +161,8 @@ Here are sub-folders (Gradle modules) for plugin source code:
- ``ppl``: PPL language processor.
- ``core``: core query engine.
- ``opensearch``: OpenSearch storage engine.
- ``prometheus``: Prometheus storage engine.
- ``filesystem``: File System storage engine (in development).
- ``protocol``: request/response protocol formatter.
- ``common``: common util code.
- ``integ-test``: integration and comparison test.
Expand Down
3 changes: 3 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Foundation (http://www.apache.org/).
This product includes software developed by
Joda.org (http://www.joda.org/).

This product includes software developed by
Kraken (https://github.com/thekrakken/java-grok).

This project is based on the Apache 2.0-licensed elasticsearch-sql project (https://github.com/NLPchina/elasticsearch-sql):

Copyright 2014 omershelef
Expand Down
30 changes: 29 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,46 @@ buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
spring_version = "5.3.22"
jackson_version = "2.13.4"
jackson_version = "2.14.1"
jackson_databind_version = "2.14.1"
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
prometheus_binary_version = "2.37.2"
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
}
if (isSnapshot) {
// 2.0.0-rc1-SNAPSHOT -> 2.0.0.0-rc1-SNAPSHOT (opensearch_build)
opensearch_build += "-SNAPSHOT"
}
getArchType = {
if (System.getProperty("os.arch").startsWith("x") || System.getProperty("os.arch").startsWith("amd")) {
return "amd64"
}
else {
return "arm64"
}
}
getOSFamilyType = {
def os = org.gradle.internal.os.OperatingSystem.current();
if (os.isMacOsX()) {
return "darwin"
}
else if(os.isLinux()){
return "linux"
}
else if(os.isWindows()) {
return "windows"
}
else {
return os.getFamilyName().toString()
}
}
getPrometheusBinaryLocation = { ->
return "https://github.com/prometheus/prometheus/releases/download/v${prometheus_binary_version}/prometheus-${prometheus_binary_version}."+ getOSFamilyType() + "-" + getArchType() + ".tar.gz"
}
}

repositories {
Expand Down
4 changes: 4 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ dependencies {
api "org.antlr:antlr4-runtime:4.7.1"
api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
api group: 'org.apache.logging.log4j', name: 'log4j-core', version:'2.17.1'
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'

testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.9.1'
testImplementation group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
}
168 changes: 168 additions & 0 deletions common/src/main/java/org/opensearch/sql/common/grok/Converter.java
Original file line number Diff line number Diff line change
@@ -0,0 +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<? extends Object> converter;
public final List<String> aliases;

Type(IConverter<? extends Object> converter, String... aliases) {
this.converter = converter;
this.aliases = Arrays.asList(aliases);
}
}

private static final Pattern SPLITTER = Pattern.compile("[:;]");

private static final Map<String, Type> TYPES =
Arrays.stream(Type.values())
.collect(Collectors.toMap(t -> t.name().toLowerCase(), t -> t));

private static final Map<String, Type> 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<String, IConverter<? extends Object>>
getConverters(Collection<String> groupNames, Object... params) {
return groupNames.stream()
.filter(Converter::containsDelimiter)
.collect(Collectors.toMap(Function.identity(), key -> {
String[] list = splitGrokPattern(key);
IConverter<? extends Object> converter = getType(list[1]).converter;
if (list.length == 3) {
converter = converter.newConverter(list[2], params);
}
return converter;
}));
}

/**
* getGroupTypes.
*/
public static Map<String, Type> getGroupTypes(Collection<String> 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> {

T convert(String value);

default IConverter<T> newConverter(String param, Object... params) {
return this;
}
}


static class DateConverter implements IConverter<Instant> {

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]);
}
}
}
Loading