implement transport api for PPL inter-plugin communication by zhongnansu · Pull Request #533 · opensearch-project/sql · GitHub
Skip to content

implement transport api for PPL inter-plugin communication#533

Merged
penghuo merged 8 commits into
opensearch-project:mainfrom
zhongnansu:ppl-transport
Jul 7, 2022
Merged

implement transport api for PPL inter-plugin communication#533
penghuo merged 8 commits into
opensearch-project:mainfrom
zhongnansu:ppl-transport

Conversation

@zhongnansu

@zhongnansu zhongnansu commented Apr 5, 2022

Copy link
Copy Markdown
Member

Signed-off-by: Zhongnan Su szhongna@amazon.com

Update

After discussion in the thread here opensearch-project/common-utils#155, we decided for now we'll keep the transport interfaces in sql repo, instead of common-utils for the following reasons.

  1. there's no consumer plugin for this feature yet. Because the response format is not encapsulated. Currently on trasnport layer there's only a json string in the response. Ideally we want a ResultSet or DataFrame like response for clients to access data. An issued is created w.r.t this.
  2. This change is to the request model, which is the input of the SQL/PPL engine. Having it separated into 2 repos is not development friendly. E.g, the CI will fail for sure, because CI only pulls against released common-utils

Description

Add a transport layer for handle PPL request. This will expose transport interface for inter-plugin communication. The existing Rest layer handler is also being refactored to make use of the transport layer

  • Create TransportPPLQueryAction

  • refactored RestPPLQueryAction to service as a route layer, moved the query request handling logic to TransportPPLQueryAction.

  • Register action and handler in SQLPlugin

  • Refactored PPLQueryRequest to be writable, for the transport layer commuication

  • Create transport response model that currently holds a string response.

  • Add common-utils as dependency, since the request/response models will be exposed in common-utils for other plugin to consume as well.

  • TODO:

    1. Request and response format are strings for now.(may need modification in future version, especially response format)
    2. Implement transport interface for SQL, in a similar manner

Issues Resolved

#521

CI/CD


| java.home: /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home
| examining directory: /Users/szhongna/Desktop/Projects/OpenSearch/sql/integ-test/build/classes/java/test
| examining directory: /Users/szhongna/Desktop/Projects/OpenSearch/sql/integ-test/build/resources/test
| examining jar: /Users/szhongna/Desktop/Projects/OpenSearch/sql/sql-jdbc/build/libs/opensearch-sql-jdbc-2.0.0.0.jar
| examining jar: /Users/szhongna/Desktop/Projects/OpenSearch/sql/sql-jdbc/build/libs/opensearch-sql-jdbc-1.2.0.0.jar
| Exception in thread "main" java.lang.IllegalStateException: jar hell!
| class: org.opensearch.jdbc.ResultSetImpl
| jar1: /Users/szhongna/Desktop/Projects/OpenSearch/sql/sql-jdbc/build/libs/opensearch-sql-jdbc-2.0.0.0.jar
| jar2: /Users/szhongna/Desktop/Projects/OpenSearch/sql/sql-jdbc/build/libs/opensearch-sql-jdbc-1.2.0.0.jar
|       at org.opensearch.bootstrap.JarHell.checkClass(JarHell.java:317)
|       at org.opensearch.bootstrap.JarHell.checkJarHell(JarHell.java:212)
|       at org.opensearch.bootstrap.JarHell.checkJarHell(JarHell.java:99)
|       at org.opensearch.bootstrap.JarHell.main(JarHell.java:83)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':integ-test:jarHell'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

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.

@zhongnansu zhongnansu marked this pull request as ready for review April 5, 2022 02:56
@zhongnansu zhongnansu requested a review from a team as a code owner April 5, 2022 02:56
@codecov-commenter

codecov-commenter commented Apr 5, 2022

Copy link
Copy Markdown

Comment thread plugin/build.gradle Outdated
Comment thread build.gradle Outdated
Comment thread plugin/src/main/java/org/opensearch/sql/plugin/transport/PPLQueryHelper.java Outdated
Comment thread plugin/src/main/java/org/opensearch/sql/plugin/transport/PPLQueryHelper.java Outdated

@penghuo penghuo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

seems missing files, SQLActions, TransportQueryResponse

@zhongnansu

Copy link
Copy Markdown
Member Author

seems missing files, SQLActions, TransportQueryResponse

@penghuo Those are interfaces that should be defined in common-utils and used by any caller plugins. Currently I have a PR pending for common-utils. Once that's merged and released to maven central, this PR will pass CI

@zhongnansu zhongnansu force-pushed the ppl-transport branch 3 times, most recently from 65b5812 to e6b6cee Compare May 10, 2022 09:35
@zhongnansu zhongnansu requested review from joshuali925 and penghuo May 10, 2022 09:36
joshuali925
joshuali925 previously approved these changes May 10, 2022

@penghuo penghuo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two things.

  1. RestSQLAction should be refactored to call TransportSQLQueryAction.
  2. Is it possible to add UT?

Comment thread plugin/src/main/java/org/opensearch/sql/plugin/transport/TransportSQLService.java Outdated
Comment thread plugin/src/main/java/org/opensearch/sql/plugin/transport/TransportSQLService.java Outdated
Comment thread plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java Outdated
Comment thread plugin/src/main/java/org/opensearch/sql/plugin/transport/TransportSQLService.java Outdated
@penghuo penghuo requested a review from dai-chen May 12, 2022 05:18
Signed-off-by: Zhongnan Su <szhongna@amazon.com>
@zhongnansu

zhongnansu commented May 24, 2022

Copy link
Copy Markdown
Member Author

Two things.

  1. RestSQLAction should be refactored to call TransportSQLQueryAction.
  2. Is it possible to add UT?

Just reply to all other comments in one thread. Thanks a lot for the advice. @penghuo

  1. I merged the TransportPPLService into transportPPLQueryAction, refactored RestPPLQueryAction to service as a route layer, moved the query request handling logic to TransportPPLQueryAction.
  2. Raise another PR Fix jarhell of common-utils ml-commons#328 to address the jarhell issue
  3. Since it will affect lots of usage in the code, I added some TODOs comments to move the PPLQueryRequest data model into common-utils. Currently we are converting the PPLQueryRequest and TransportPPLQueryRequest(common-utils) manually.
  4. Update PR in common-utils to refactor TrasnportPPLQueryRequest model, also moved Style enum from sql to common-utils since it's also used in PPLQueryRequest and SQLQueryRequest. add SQL/PPL transport request/response models common-utils#155

Comment thread plugin/build.gradle Outdated
Comment thread plugin/src/main/java/org/opensearch/sql/plugin/rest/RestPPLQueryAction.java Outdated
@zhongnansu

Copy link
Copy Markdown
Member Author

Addressed all comments. Local build keeps failing during ./gradlew build, > Task :integ-test:jarHell FAILED

| sun.boot.class.path: null
| java.home: /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home
| examining directory: /Users/szhongna/Desktop/Projects/OpenSearch/sql/integ-test/build/classes/java/test
| examining directory: /Users/szhongna/Desktop/Projects/OpenSearch/sql/integ-test/build/resources/test
| examining jar: /Users/szhongna/Desktop/Projects/OpenSearch/sql/sql-jdbc/build/libs/opensearch-sql-jdbc-2.0.0.0.jar
| examining jar: /Users/szhongna/Desktop/Projects/OpenSearch/sql/sql-jdbc/build/libs/opensearch-sql-jdbc-1.2.0.0.jar
| Exception in thread "main" java.lang.IllegalStateException: jar hell!
| class: org.opensearch.jdbc.ResultSetImpl
| jar1: /Users/szhongna/Desktop/Projects/OpenSearch/sql/sql-jdbc/build/libs/opensearch-sql-jdbc-2.0.0.0.jar
| jar2: /Users/szhongna/Desktop/Projects/OpenSearch/sql/sql-jdbc/build/libs/opensearch-sql-jdbc-1.2.0.0.jar
|       at org.opensearch.bootstrap.JarHell.checkClass(JarHell.java:317)
|       at org.opensearch.bootstrap.JarHell.checkJarHell(JarHell.java:212)
|       at org.opensearch.bootstrap.JarHell.checkJarHell(JarHell.java:99)
|       at org.opensearch.bootstrap.JarHell.main(JarHell.java:83)

It doesn't related to my change. Any idea how can I resolve this? @penghuo @joshuali925

@zhongnansu zhongnansu requested review from joshuali925 and penghuo May 25, 2022 22:04
@zhongnansu

Copy link
Copy Markdown
Member Author

doctest and gradle test gradle integTest can pass

@penghuo

penghuo commented May 25, 2022

Copy link
Copy Markdown
Collaborator

build/libs/opensearch-sql-jdbc-1.2.0.0.jar

clean you local build folder will help.

Signed-off-by: Zhongnan Su <szhongna@amazon.com>
Signed-off-by: Zhongnan Su <szhongna@amazon.com>
Signed-off-by: Zhongnan Su <szhongna@amazon.com>
@zhongnansu zhongnansu changed the title implement transport api for inter-plugin communication implement transport api for PPL inter-plugin communication May 31, 2022
Signed-off-by: Zhongnan Su <szhongna@amazon.com>
Signed-off-by: Zhongnan Su <szhongna@amazon.com>
@zhongnansu

Copy link
Copy Markdown
Member Author

Comment thread ppl/build.gradle Outdated
Signed-off-by: Zhongnan Su <szhongna@amazon.com>
Signed-off-by: Zhongnan Su <szhongna@amazon.com>
@zhongnansu zhongnansu requested a review from penghuo June 25, 2022 00:02

@penghuo penghuo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the change!

@penghuo penghuo added the v3.0.0 label Jun 25, 2022
@penghuo penghuo merged commit 166376f into opensearch-project:main Jul 7, 2022
penghuo pushed a commit to penghuo/os-sql that referenced this pull request Aug 18, 2022
penghuo added a commit that referenced this pull request Aug 18, 2022
Signed-off-by: Zhongnan Su <szhongna@amazon.com>

Signed-off-by: Zhongnan Su <szhongna@amazon.com>
Co-authored-by: Zhongnan Su <szhongna@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants