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

Enhance AggregationFuzzer to verify results against Spark #9270

Open
rui-mo opened this issue Mar 27, 2024 · 10 comments
Open

Enhance AggregationFuzzer to verify results against Spark #9270

rui-mo opened this issue Mar 27, 2024 · 10 comments
Labels
enhancement New feature or request

Comments

@rui-mo
Copy link
Collaborator

rui-mo commented Mar 27, 2024

Description

Currently, Aggregation Fuzzer verifies results against DuckDB. However, not all functions are available in DuckDB and sometimes semantics don't match. It would be better to verify against Spark.

After several rounds of investigation, we would like to implement the SparkQueryRunner based on Spark Connect. In Spark 3.4, Spark Connect introduced a decoupled client-server architecture for Spark that allows remote connectivity to Spark clusters as described in spark-connect-overview. From the client perspective, Spark Connect mostly behaves as any other gRPC client, which is polyglot and and cross-platforms. Protocols used by Spark Connect are proto files defined in https://github.com/apache/spark/tree/master/connector/connect/common/src/main/protobuf/spark/connect.

Start Spark Connect server
Firstly, we need to deploy an executable Spark, and download spark-connect_2.12-3.5.1.jar from https://repo1.maven.org/maven2/org/apache/spark/spark-connect_2.12/3.5.1/.
Then in $SPARK_HOME, we can start Spark Connect server with below command.
./sbin/start-connect-server.sh --jars $SPARK_HOME/jars/spark-connect_2.12-3.5.1.jar
If the sever is started successfully, we can see log as below.
INFO SparkConnectServer: Spark Connect server started at: 0:0:0:0:0:0:0:0%0:15002

Work with Spark Connect to submit query and get the result
Below diagram illustrates how query is submitted from native to Spark through Spark Connect for execution. Firstly, we create a protobuf message ExecutePlanRequest from a string query based on defined protocols. Then we submit the message to a gRPC API ExecutePlan for execution, and result can be read from its response. Since Spark stores data in Arrow IPC stream format, arrow::ipc::RecordBatchReader is used to read bytes as Arrow RecordBatch. By converting Arrow RecordBatch as Velox vector, we can compare the results of Spark and Velox.
We have implemented a prototype SparkClient.cpp and verified its functionality. It could submit a query to Spark and fetch the results back to native.

Untitled Diagram

@rui-mo rui-mo added the enhancement New feature or request label Mar 27, 2024
@rui-mo
Copy link
Collaborator Author

rui-mo commented Mar 27, 2024

#6595 (comment)

@rui-mo
Copy link
Collaborator Author

rui-mo commented Mar 27, 2024

Let's track the updates of SparkQueryRunner here. cc: @mbasmanova @zhztheplayer

@mbasmanova
Copy link
Contributor

CC: @kgpai @kagamiori

@mbasmanova
Copy link
Contributor

CC: @amitkdutta

@rui-mo
Copy link
Collaborator Author

rui-mo commented Apr 9, 2024

Hi @mbasmanova, I have updated our recent updates in this issue. Your feedback is appreciated, thanks. cc: @FelixYBW

@mbasmanova
Copy link
Contributor

@rui-mo Rui, this is great. Looks like you have a working prototype. What would be the next steps towards "productizing" this?

CC: @kgpai @assignUser @duanmeng

@rui-mo
Copy link
Collaborator Author

rui-mo commented Apr 10, 2024

@mbasmanova If this approach makes sense in Velox, we plan to introduce the Spark client as well as the Spark connect protocols into Velox, and start to enhance the aggregation fuzzer based on them. To test against Spark, we would like to know where we can set-up the Spark environment needed for execution, thanks.

@assignUser
Copy link
Collaborator

assignUser commented Apr 10, 2024

where we can set-up the Spark environment needed for execution

What's the requirement for this? I assume this would be more inline of an ephemeral test setup (e.g. how we use hadoop on the adapters test) and not a permanent production grade thing?

We could add spark, spark connect and deps to the adapers docker image. I think it's also possible to run additional containers as serviced in a github action job but I haven't used that feature yet.

@rui-mo
Copy link
Collaborator Author

rui-mo commented Apr 10, 2024

I assume this would be more inline of an ephemeral test setup

@assignUser Yes, you are right. Could you provide us a reference on how hadoop or presto is deployed in the test? I assume we can deploy spark in a similar way. Thank you.

@assignUser
Copy link
Collaborator

It looks like the tests themselves start hadoop/azurite for example see connectors/hive/storage_adapters/hive/tests
If you show me how you setup spark for your poc tests (e.g. your bash script) I can help with getting that setup in an action.

Here is the service container reference, sounds useful https://docs.github.com/en/actions/using-containerized-services/about-service-containers

facebook-github-bot pushed a commit that referenced this issue May 29, 2024
Summary:
Add support for docker image with Spark connect server for fuzzer test to use.
#9270

Pull Request resolved: #9759

Reviewed By: Yuhta

Differential Revision: D57726964

Pulled By: kgpai

fbshipit-source-id: 41a1e93dcf31c1ac1ab7e1529992ca8efc26c7ab
Joe-Abraham pushed a commit to Joe-Abraham/velox that referenced this issue Jun 7, 2024
…ator#9759)

Summary:
Add support for docker image with Spark connect server for fuzzer test to use.
facebookincubator#9270

Pull Request resolved: facebookincubator#9759

Reviewed By: Yuhta

Differential Revision: D57726964

Pulled By: kgpai

fbshipit-source-id: 41a1e93dcf31c1ac1ab7e1529992ca8efc26c7ab
Joe-Abraham pushed a commit to Joe-Abraham/velox that referenced this issue Jun 7, 2024
…ator#9759)

Summary:
Add support for docker image with Spark connect server for fuzzer test to use.
facebookincubator#9270

Pull Request resolved: facebookincubator#9759

Reviewed By: Yuhta

Differential Revision: D57726964

Pulled By: kgpai

fbshipit-source-id: 41a1e93dcf31c1ac1ab7e1529992ca8efc26c7ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants