-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor] Extend REPL to support external metadata storage and data …
…storage (#381) (#605) * REPL refactor * Ignore UT * Add seqNo and primaryTerm to session object * Address os client concurrency limitation * Add interface for query execution * Clean up logs and add UTs * Clean up and fix UTs --------- (cherry picked from commit aa509ac) Signed-off-by: Louis Chu <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
cdb498f
commit ad5697b
Showing
21 changed files
with
1,328 additions
and
748 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
flint-commons/src/main/scala/org/apache/spark/sql/QueryResultWriter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.apache.spark.sql | ||
|
||
import org.opensearch.flint.common.model.FlintStatement | ||
|
||
/** | ||
* Trait for writing the result of a query execution to an external data storage. | ||
*/ | ||
trait QueryResultWriter { | ||
|
||
/** | ||
* Writes the given DataFrame, which represents the result of a query execution, to an external | ||
* data storage based on the provided FlintStatement metadata. | ||
*/ | ||
def writeDataFrame(dataFrame: DataFrame, flintStatement: FlintStatement): Unit | ||
} |
43 changes: 43 additions & 0 deletions
43
flint-commons/src/main/scala/org/apache/spark/sql/SessionManager.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.apache.spark.sql | ||
|
||
import org.opensearch.flint.common.model.{FlintStatement, InteractiveSession} | ||
|
||
import org.apache.spark.sql.SessionUpdateMode.SessionUpdateMode | ||
|
||
/** | ||
* Trait defining the interface for managing interactive sessions. | ||
*/ | ||
trait SessionManager { | ||
|
||
/** | ||
* Retrieves metadata about the session manager. | ||
*/ | ||
def getSessionContext: Map[String, Any] | ||
|
||
/** | ||
* Fetches the details of a specific session. | ||
*/ | ||
def getSessionDetails(sessionId: String): Option[InteractiveSession] | ||
|
||
/** | ||
* Updates the details of a specific session. | ||
*/ | ||
def updateSessionDetails( | ||
sessionDetails: InteractiveSession, | ||
updateMode: SessionUpdateMode): Unit | ||
|
||
/** | ||
* Records a heartbeat for a specific session to indicate it is still active. | ||
*/ | ||
def recordHeartbeat(sessionId: String): Unit | ||
} | ||
|
||
object SessionUpdateMode extends Enumeration { | ||
type SessionUpdateMode = Value | ||
val UPDATE, UPSERT, UPDATE_IF = Value | ||
} |
42 changes: 42 additions & 0 deletions
42
flint-commons/src/main/scala/org/apache/spark/sql/StatementExecutionManager.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.apache.spark.sql | ||
|
||
import org.opensearch.flint.common.model.FlintStatement | ||
|
||
/** | ||
* Trait defining the interface for managing FlintStatement execution. For example, in FlintREPL, | ||
* multiple FlintStatements are running in a micro-batch within same session. | ||
* | ||
* This interface can also apply to other spark entry point like FlintJob. | ||
*/ | ||
trait StatementExecutionManager { | ||
|
||
/** | ||
* Prepares execution of each individual statement | ||
*/ | ||
def prepareStatementExecution(): Either[String, Unit] | ||
|
||
/** | ||
* Executes a specific statement and returns the spark dataframe | ||
*/ | ||
def executeStatement(statement: FlintStatement): DataFrame | ||
|
||
/** | ||
* Retrieves the next statement to be executed. | ||
*/ | ||
def getNextStatement(): Option[FlintStatement] | ||
|
||
/** | ||
* Updates a specific statement. | ||
*/ | ||
def updateStatement(statement: FlintStatement): Unit | ||
|
||
/** | ||
* Terminates the statement lifecycle. | ||
*/ | ||
def terminateStatementsExecution(): Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.