-
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.
- Loading branch information
Showing
5 changed files
with
156 additions
and
96 deletions.
There are no files selected for viewing
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
51 changes: 51 additions & 0 deletions
51
spark-sql-application/src/main/scala/org/apache/spark/sql/QueryExecutionManagerImpl.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,51 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.apache.spark.sql | ||
|
||
import org.opensearch.flint.data.FlintStatement | ||
|
||
import org.apache.spark.internal.Logging | ||
|
||
class QueryExecutionManagerImpl(context: Map[String, Any]) | ||
extends QueryExecutionManager | ||
with FlintJobExecutor | ||
with Logging { | ||
val osClient = context("osClient").asInstanceOf[OSClient] | ||
val resultIndex = context("osClient").asInstanceOf[String] | ||
|
||
override def prepareQueryExecution(): Either[String, Unit] = { | ||
try { | ||
val existingSchema = osClient.getIndexMetadata(resultIndex) | ||
if (!isSuperset(existingSchema, resultIndexMapping)) { | ||
Left(s"The mapping of $resultIndex is incorrect.") | ||
} else { | ||
Right(()) | ||
} | ||
} catch { | ||
case e: IllegalStateException | ||
if e.getCause != null && | ||
e.getCause.getMessage.contains("index_not_found_exception") => | ||
createResultIndex(osClient, resultIndex, resultIndexMapping) | ||
case e: InterruptedException => | ||
val error = s"Interrupted by the main thread: ${e.getMessage}" | ||
Thread.currentThread().interrupt() // Preserve the interrupt status | ||
logError(error, e) | ||
Left(error) | ||
case e: Exception => | ||
val error = s"Failed to verify existing mapping: ${e.getMessage}" | ||
logError(error, e) | ||
Left(error) | ||
} | ||
} | ||
|
||
override def initCommandLifecycle(sessionId: String): FlintStatement = ??? | ||
|
||
override def closeCommandLifecycle(): Unit = ??? | ||
|
||
override def getNextStatement(statement: FlintStatement): Option[FlintStatement] = ??? | ||
|
||
override def updateStatement(statement: FlintStatement): Unit = ??? | ||
} |
Oops, something went wrong.