Skip to content

Commit

Permalink
[Feature] Flint query scheduler part1 - integrate job scheduler plugin
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 16, 2024
1 parent 0c2e1da commit b29ffc4
Show file tree
Hide file tree
Showing 23 changed files with 955 additions and 35 deletions.
1 change: 1 addition & 0 deletions async-query-core/src/main/antlr/SqlBaseLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ NANOSECOND: 'NANOSECOND';
NANOSECONDS: 'NANOSECONDS';
NATURAL: 'NATURAL';
NO: 'NO';
NONE: 'NONE';
NOT: 'NOT';
NULL: 'NULL';
NULLS: 'NULLS';
Expand Down
20 changes: 18 additions & 2 deletions async-query-core/src/main/antlr/SqlBaseParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ singleCompoundStatement
;

beginEndCompoundBlock
: BEGIN compoundBody END
: beginLabel? BEGIN compoundBody END endLabel?
;

compoundBody
Expand All @@ -68,6 +68,14 @@ singleStatement
: statement SEMICOLON* EOF
;

beginLabel
: multipartIdentifier COLON
;

endLabel
: multipartIdentifier
;

singleExpression
: namedExpression EOF
;
Expand Down Expand Up @@ -174,6 +182,8 @@ statement
| ALTER TABLE identifierReference
(partitionSpec)? SET locationSpec #setTableLocation
| ALTER TABLE identifierReference RECOVER PARTITIONS #recoverPartitions
| ALTER TABLE identifierReference
(clusterBySpec | CLUSTER BY NONE) #alterClusterBy
| DROP TABLE (IF EXISTS)? identifierReference PURGE? #dropTable
| DROP VIEW (IF EXISTS)? identifierReference #dropView
| CREATE (OR REPLACE)? (GLOBAL? TEMPORARY)?
Expand Down Expand Up @@ -853,13 +863,17 @@ identifierComment

relationPrimary
: identifierReference temporalClause?
sample? tableAlias #tableName
optionsClause? sample? tableAlias #tableName
| LEFT_PAREN query RIGHT_PAREN sample? tableAlias #aliasedQuery
| LEFT_PAREN relation RIGHT_PAREN sample? tableAlias #aliasedRelation
| inlineTable #inlineTableDefault2
| functionTable #tableValuedFunction
;

optionsClause
: WITH options=propertyList
;

inlineTable
: VALUES expression (COMMA expression)* tableAlias
;
Expand Down Expand Up @@ -1572,6 +1586,7 @@ ansiNonReserved
| NANOSECOND
| NANOSECONDS
| NO
| NONE
| NULLS
| NUMERIC
| OF
Expand Down Expand Up @@ -1920,6 +1935,7 @@ nonReserved
| NANOSECOND
| NANOSECONDS
| NO
| NONE
| NOT
| NULL
| NULLS
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
*/

package org.opensearch.sql.spark.scheduler;

public interface AsyncQueryScheduler {
void scheduleJob(AsyncQuerySchedulerJobRequest request);

void unscheduleJob(AsyncQuerySchedulerJobRequest request);

void removeJob(AsyncQuerySchedulerJobRequest request);

void updateJob(AsyncQuerySchedulerJobRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.sql.spark.scheduler;

public interface AsyncQuerySchedulerJob {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.sql.spark.scheduler;

public abstract class AsyncQuerySchedulerJobRequest {
private final String id;
private final String jobName;
private final String jobType;
private final String schedule;
private final boolean enabled;

protected AsyncQuerySchedulerJobRequest(Builder<?> builder) {
this.id = builder.id;
this.jobName = builder.jobName;
this.jobType = builder.jobType;
this.schedule = builder.schedule;
this.enabled = builder.enabled;
}

public String getId() {
return id;
}

public String getJobName() {
return jobName;
}

public String getJobType() {
return jobType;
}

public String getRawSchedule() {
return schedule;
}

public boolean isEnabled() {
return enabled;
}

public abstract static class Builder<T extends Builder<T>> {
private String id;
private String jobName;
private String jobType;
private String schedule;
private boolean enabled;

public T withId(String id) {
this.id = id;
return self();
}

public T withJobName(String jobName) {
this.jobName = jobName;
return self();
}

public T withJobType(String jobType) {
this.jobType = jobType;
return self();
}

public T withSchedule(String schedule) {
this.schedule = schedule;
return self();
}

public T withEnabled(boolean enabled) {
this.enabled = enabled;
return self();
}

protected abstract T self();

public abstract AsyncQuerySchedulerJobRequest build();
}
}
2 changes: 2 additions & 0 deletions async-query/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ repositories {


dependencies {
compileOnly "org.opensearch:opensearch-job-scheduler-spi:${opensearch_build}"

api project(':core')
api project(':async-query-core')
implementation project(':protocol')
Expand Down
Loading

0 comments on commit b29ffc4

Please sign in to comment.