Skip to content

Commit

Permalink
clean up doc test
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chu <clingzhi@amazon.com>
  • Loading branch information
noCharger committed Jul 24, 2024
1 parent b8a586e commit 2b69b66
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 53 deletions.
17 changes: 11 additions & 6 deletions async-query-core/src/main/antlr/SqlBaseParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ compoundStatement
;

setStatementWithOptionalVarKeyword
: SET (VARIABLE | VAR)? assignmentList #setVariableWithOptionalKeyword
| SET (VARIABLE | VAR)? LEFT_PAREN multipartIdentifierList RIGHT_PAREN EQ
: SET variable? assignmentList #setVariableWithOptionalKeyword
| SET variable? LEFT_PAREN multipartIdentifierList RIGHT_PAREN EQ
LEFT_PAREN query RIGHT_PAREN #setVariableWithOptionalKeyword
;

Expand Down Expand Up @@ -215,9 +215,9 @@ statement
routineCharacteristics
RETURN (query | expression) #createUserDefinedFunction
| DROP TEMPORARY? FUNCTION (IF EXISTS)? identifierReference #dropFunction
| DECLARE (OR REPLACE)? VARIABLE?
| DECLARE (OR REPLACE)? variable?
identifierReference dataType? variableDefaultExpression? #createVariable
| DROP TEMPORARY VARIABLE (IF EXISTS)? identifierReference #dropVariable
| DROP TEMPORARY variable (IF EXISTS)? identifierReference #dropVariable
| EXPLAIN (LOGICAL | FORMATTED | EXTENDED | CODEGEN | COST)?
(statement|setResetStatement) #explain
| SHOW TABLES ((FROM | IN) identifierReference)?
Expand Down Expand Up @@ -272,8 +272,8 @@ setResetStatement
| SET TIME ZONE interval #setTimeZone
| SET TIME ZONE timezone #setTimeZone
| SET TIME ZONE .*? #setTimeZone
| SET (VARIABLE | VAR) assignmentList #setVariable
| SET (VARIABLE | VAR) LEFT_PAREN multipartIdentifierList RIGHT_PAREN EQ
| SET variable assignmentList #setVariable
| SET variable LEFT_PAREN multipartIdentifierList RIGHT_PAREN EQ
LEFT_PAREN query RIGHT_PAREN #setVariable
| SET configKey EQ configValue #setQuotedConfiguration
| SET configKey (EQ .*?)? #setConfiguration
Expand Down Expand Up @@ -438,6 +438,11 @@ namespaces
| SCHEMAS
;

variable
: VARIABLE
| VAR
;

describeFuncName
: identifierReference
| stringLit
Expand Down
90 changes: 47 additions & 43 deletions doctest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,49 +139,7 @@ testClusters {
}
}))
*/
plugin(provider(new Callable<RegularFile>(){
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
// Use absolute paths
String basePath = new File('.').getCanonicalPath()
File dir = new File(basePath + File.separator + 'doctest' + File.separator + jsPlugin)

// Log the directory path for debugging
println("Creating directory: " + dir.getAbsolutePath())

// Create directory if it doesn't exist
if (!dir.exists()) {
if (!dir.mkdirs()) {
throw new IOException("Failed to create directory: " + dir.getAbsolutePath())
}
}

// Define the file path
File f = new File(dir, jsPlugin + '-' + opensearch_build + '.zip')

// Download file if it doesn't exist
if (!f.exists()) {
println("Downloading file from: " + bwcOpenSearchJSDownload)
println("Saving to file: " + f.getAbsolutePath())

new URL(bwcOpenSearchJSDownload).withInputStream { ins ->
f.withOutputStream { it << ins }
}
}

// Check if the file was created successfully
if (!f.exists()) {
throw new FileNotFoundException("File was not created: " + f.getAbsolutePath())
}

return fileTree(f.getParent()).matching { include f.getName() }.singleFile
}
}
}
}))
plugin(getJobSchedulerPlugin(jsPlugin, bwcOpenSearchJSDownload))
plugin ':opensearch-sql-plugin'
testDistribution = 'archive'
}
Expand All @@ -208,3 +166,49 @@ spotless {
googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format')
}
}

def getJobSchedulerPlugin(String jsPlugin, String bwcOpenSearchJSDownload) {
return provider(new Callable<RegularFile>() {
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
// Use absolute paths
String basePath = new File('.').getCanonicalPath()
File dir = new File(basePath + File.separator + 'doctest' + File.separator + jsPlugin)

// Log the directory path for debugging
println("Creating directory: " + dir.getAbsolutePath())

// Create directory if it doesn't exist
if (!dir.exists()) {
if (!dir.mkdirs()) {
throw new IOException("Failed to create directory: " + dir.getAbsolutePath())
}
}

// Define the file path
File f = new File(dir, jsPlugin + '-' + opensearch_build + '.zip')

// Download file if it doesn't exist
if (!f.exists()) {
println("Downloading file from: " + bwcOpenSearchJSDownload)
println("Saving to file: " + f.getAbsolutePath())

new URL(bwcOpenSearchJSDownload).withInputStream { ins ->
f.withOutputStream { it << ins }
}
}

// Check if the file was created successfully
if (!f.exists()) {
throw new FileNotFoundException("File was not created: " + f.getAbsolutePath())
}

return fileTree(f.getParent()).matching { include f.getName() }.singleFile
}
}
}
})
}
4 changes: 0 additions & 4 deletions integ-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
useCluster testClusters."${baseName}0"
dependsOn "${baseName}#oldVersionClusterTask0"
doFirst {
println "List of plugins: $plugins"
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
}
filter {
Expand All @@ -620,7 +619,6 @@ task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTas
dependsOn "${baseName}#mixedClusterTask"
useCluster testClusters."${baseName}0"
doFirst {
println "List of plugins: $plugins"
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
}
filter {
Expand All @@ -640,7 +638,6 @@ task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask)
dependsOn "${baseName}#twoThirdsUpgradedClusterTask"
useCluster testClusters."${baseName}0"
doFirst {
println "List of plugins: $plugins"
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
}
filter {
Expand All @@ -660,7 +657,6 @@ task "${baseName}#fullRestartClusterTask"(type: StandaloneRestIntegTestTask) {
dependsOn "${baseName}#oldVersionClusterTask1"
useCluster testClusters."${baseName}1"
doFirst {
println "List of plugins: $plugins"
testClusters."${baseName}1".upgradeAllNodesAndPluginsToNextVersion(plugins)
}
filter {
Expand Down

0 comments on commit 2b69b66

Please sign in to comment.