diff --git a/async-query-core/src/main/antlr/SqlBaseParser.g4 b/async-query-core/src/main/antlr/SqlBaseParser.g4 index c7aa56cf92..841c94d786 100644 --- a/async-query-core/src/main/antlr/SqlBaseParser.g4 +++ b/async-query-core/src/main/antlr/SqlBaseParser.g4 @@ -63,6 +63,7 @@ compoundStatement : statement | setStatementWithOptionalVarKeyword | beginEndCompoundBlock + | ifElseStatement ; setStatementWithOptionalVarKeyword @@ -71,6 +72,12 @@ setStatementWithOptionalVarKeyword LEFT_PAREN query RIGHT_PAREN #setVariableWithOptionalKeyword ; +ifElseStatement + : IF booleanExpression THEN conditionalBodies+=compoundBody + (ELSE IF booleanExpression THEN conditionalBodies+=compoundBody)* + (ELSE elseBody=compoundBody)? END IF + ; + singleStatement : (statement|setResetStatement) SEMICOLON* EOF ; diff --git a/integ-test/build.gradle b/integ-test/build.gradle index c308f7c602..08b0e545c7 100644 --- a/integ-test/build.gradle +++ b/integ-test/build.gradle @@ -136,18 +136,6 @@ ext { cluster.plugin provider((Callable) (() -> (RegularFile) (() -> downloadedSecurityPlugin))) } - bwcFilePath = "src/test/resources/bwc/" - bwcMinVersion = "1.1.0.0" - bwcBundleVersion = "1.3.2.0" - bwcBundleTest = (project.findProperty('customDistributionDownloadType') != null && - project.properties['customDistributionDownloadType'] == "bundle"); - bwcVersion = bwcBundleTest ? bwcBundleVersion : bwcMinVersion - // Create bwcVersionShort without the last digit - bwcVersionShort = bwcVersion.substring(0, bwcVersion.lastIndexOf('.')) - - bwcOpenSearchJSDownload = 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/' + bwcVersionShort + '/latest/linux/x64/tar/builds/' + - 'opensearch/plugins/opensearch-job-scheduler-' + bwcVersion + '.zip' - bwcJobSchedulerPath = bwcFilePath + "job-scheduler/" } tasks.withType(licenseHeaders.class) { @@ -157,10 +145,6 @@ tasks.withType(licenseHeaders.class) { validateNebulaPom.enabled = false loggerUsageCheck.enabled = false -configurations { - zipArchive -} - configurations.all { resolutionStrategy.force 'junit:junit:4.13.2' resolutionStrategy.force "commons-logging:commons-logging:1.2" @@ -197,9 +181,6 @@ dependencies { testImplementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.41.2.2' testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9' testCompileOnly 'org.apiguardian:apiguardian-api:1.1.2' - - // Needed for BWC tests - zipArchive group: 'org.opensearch.plugin', name:'opensearch-job-scheduler', version: "${opensearch_build}" } dependencyLicenses.enabled = false @@ -222,22 +203,6 @@ testClusters.all { } } -def getJobSchedulerPlugin() { - provider(new Callable() { - @Override - RegularFile call() throws Exception { - return new RegularFile() { - @Override - File getAsFile() { - return configurations.zipArchive.asFileTree.matching { - include '**/opensearch-job-scheduler*' - }.singleFile - } - } - } - }) -} - testClusters { integTest { testDistribution = 'archive' @@ -519,10 +484,20 @@ task comparisonTest(type: RestIntegTestTask) { systemProperty "queries", System.getProperty("queries") } +String bwcMinVersion = "1.1.0.0" +String bwcBundleVersion = "1.3.2.0" +Boolean bwcBundleTest = (project.findProperty('customDistributionDownloadType') != null && + project.properties['customDistributionDownloadType'] == "bundle"); +String bwcVersion = bwcBundleTest ? bwcBundleVersion : bwcMinVersion String currentVersion = opensearch_version.replace("-SNAPSHOT","") String baseName = "sqlBwcCluster" +String bwcFilePath = "src/test/resources/bwc/" +String bwcJSPluginPath = bwcFilePath + "job-scheduler/" String bwcSqlPlugin = "opensearch-sql-" + bwcVersion + ".zip" -String bwcRemoteFile = "https://ci.opensearch.org/ci/dbc/bundle-build/1.1.0/20210930/linux/x64/builds/opensearch/plugins/" + bwcSqlPlugin +String bwcJSPlugin = "opensearch-job-scheduler-" + bwcVersion + ".zip" +String bwcRemoteFileRoot = "https://ci.opensearch.org/ci/dbc/bundle-build/1.1.0/20210930/linux/x64/builds/opensearch/plugins/" +String bwcRemoteFileSqlPlugin = bwcRemoteFileRoot + bwcSqlPlugin +String bwcRemoteFileJSPlugin = bwcRemoteFileRoot + bwcJSPlugin 2.times { i -> testClusters { @@ -557,20 +532,21 @@ String bwcRemoteFile = "https://ci.opensearch.org/ci/dbc/bundle-build/1.1.0/2021 } } else { versions = ["1.1.0", opensearch_version] - plugin(provider(new Callable(){ + plugin(provider(new Callable() { @Override RegularFile call() throws Exception { return new RegularFile() { @Override File getAsFile() { - if (new File("$project.rootDir/$bwcFilePath/job-scheduler/$bwcVersion").exists()) { - project.delete(files("$project.rootDir/$bwcFilePath/job-scheduler/$bwcVersion")) + File dir = new File('./integ-test/' + bwcJSPluginPath + bwcVersion) + if (!dir.exists()) { + dir.mkdirs() } - project.mkdir bwcJobSchedulerPath + bwcVersion - ant.get(src: bwcOpenSearchJSDownload, - dest: bwcJobSchedulerPath + bwcVersion, - httpusecaches: false) - return fileTree(bwcJobSchedulerPath + bwcVersion).getSingleFile() + File f = new File(dir, bwcJSPlugin) + if (!f.exists()) { + new URL(bwcRemoteFileJSPlugin).withInputStream{ ins -> f.withOutputStream{ it << ins }} + } + return fileTree(bwcJSPluginPath + bwcVersion).getSingleFile() } } } @@ -587,7 +563,7 @@ String bwcRemoteFile = "https://ci.opensearch.org/ci/dbc/bundle-build/1.1.0/2021 } File f = new File(dir, bwcSqlPlugin) if (!f.exists()) { - new URL(bwcRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }} + new URL(bwcRemoteFileSqlPlugin).withInputStream{ ins -> f.withOutputStream{ it << ins }} } return fileTree(bwcFilePath + bwcVersion).getSingleFile() } @@ -601,6 +577,20 @@ String bwcRemoteFile = "https://ci.opensearch.org/ci/dbc/bundle-build/1.1.0/2021 } } +def getJobSchedulerPlugin() { + provider(new Callable() { + @Override + RegularFile call() throws Exception { + return new RegularFile() { + @Override + File getAsFile() { + return fileTree(bwcJSPluginPath + project.version).getSingleFile() + } + } + } + }) +} + List> plugins = [ getJobSchedulerPlugin(), provider(new Callable() {