Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resultIndex to session manager extension #689

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

noCharger
Copy link
Collaborator

@noCharger noCharger commented Sep 24, 2024

Description

Add resultIndex to session manager extension constructor. In this case custom session manager can work with default QueryResultWriter to persist result to OpenSearch

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@@ -983,7 +983,8 @@ object FlintREPL extends Logging with FlintJobExecutor {
resultIndexOption: Option[String]): SessionManager = {
instantiate(
new SessionManagerImpl(spark, resultIndexOption),
spark.conf.get(FlintSparkConf.CUSTOM_SESSION_MANAGER.key, ""))
spark.conf.get(FlintSparkConf.CUSTOM_SESSION_MANAGER.key, ""),
resultIndexOption)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm: custom session manager constructor in Java can accept Scala's Option[String]?

Copy link
Collaborator Author

@noCharger noCharger Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java project needs to add Scala's library. For example

import scala.Option;
import scala.Some;
import scala.None$;

MyClass myClass = new MyClass(Some.apply("Hello")); // using Scala's Some

But I think it makes more sense to convert this as String for ease of use


class QueryResultWriterImpl(context: Map[String, Any]) extends QueryResultWriter with Logging {

private val resultIndex = context("resultIndex").asInstanceOf[String]
private val osClient = context("osClient").asInstanceOf[OSClient]
private val osClient = new OSClient(FlintSparkConf().flintOptions())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry could you elaborate this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default session manager impl keeps an OSClient in context map and expose it to OpenSearch QueryResultWriter. For the custom session manager, it doesn't make sense to do so to work with OpenSearch QueryResultWriter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit unintuitive.
Could we add a comment here? Because if we're just reading the code (our OpenSearch implementations) we might wonder why we're not using the osClient available in context.
If I'm understanding correctly, here we're not using context("osClient") because we can't rely on the session manager implementation to put osClient in context?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, comment added

@noCharger noCharger merged commit f742a65 into opensearch-project:main Sep 24, 2024
4 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 24, 2024
Signed-off-by: Louis Chu <[email protected]>
(cherry picked from commit f742a65)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 24, 2024
Signed-off-by: Louis Chu <[email protected]>
(cherry picked from commit f742a65)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
noCharger pushed a commit that referenced this pull request Sep 24, 2024
(cherry picked from commit f742a65)

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>
noCharger pushed a commit that referenced this pull request Sep 24, 2024
(cherry picked from commit f742a65)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants