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

Iceberg/Comet integration POC #9841

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Iceberg/Comet integration POC #9841

wants to merge 14 commits into from

Conversation

huaxingao
Copy link
Contributor

@huaxingao huaxingao commented Mar 1, 2024

This PR shows how I will integrate Comet with iceberg. The PR doesn't compile yet because we haven't released Comet yet, but it shows the ideas how we are going to change iceberg code to integrate Comet. Also, Comet doesn't have Spark3.5 support yet so I am doing this on 3.4, but we will add 3.5 support in Comet.

In VectorizedSparkParquetReaders.buildReader, if Comet library is available, a CometIcebergColumnarBatchReader will be created, which will use Comet batch reader to read data. We can also add a property later to control whether we want to use Comet or not.

The logic in CometIcebergVectorizedReaderBuilder is very similar to VectorizedReaderBuilder. It builds Comet column reader instead of iceberg column reader.

The delete logic in CometIcebergColumnarBatchReader is exactly the same as the one in ColumnarBatchReader. I will extract the common code and put the common code in a base class.

The main motivation of this PR is to improve performance using native execution. Comet's Parquet reader is a hybrid implementation: IO and decompression are done in the JVM while decoding is done natively. There is some performance gain from native decoding, but the gain is not much. However, by switching to the Comet Parquet reader, Comet will recognize that this is a Comet scan and will convert the Spark physical plan into a Comet plan for native execution. The major performance gain will be from this native execution.

@huaxingao
Copy link
Contributor Author

cc @aokolnychyi @sunchao

Copy link
Contributor

@aokolnychyi aokolnychyi left a comment

Choose a reason for hiding this comment

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

I think this is the right direction to take. I did an initial high-level pass. Looking forward to having a Comet release soon.

}

compileOnly "org.apache.comet:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.1.0-SNAPSHOT"
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this library will only contain the reader, not the operators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. This only contains the reader.

Copy link
Member

Choose a reason for hiding this comment

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

Does it need to be Spark Version Dependent? Just wondering

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are currently doing some experiments to see if we can provide a Spark Version independent jar.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for exploring that.

@github-actions github-actions bot added the API label Apr 18, 2024
api/src/main/java/org/apache/iceberg/ReaderType.java Outdated Show resolved Hide resolved
@@ -45,6 +45,7 @@ buildscript {
}
}

String sparkMajorVersion = '3.4'
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope we can soon have a snapshot for Comet jar independent of Spark to clean up deps here.
We can't have parquet module depend on a jar with any Spark deps.

spark/v3.4/build.gradle Outdated Show resolved Hide resolved
}

compileOnly "org.apache.comet:comet-spark-spark${sparkMajorVersion}_${scalaVersion}:0.1.0-SNAPSHOT"
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for exploring that.

gradle.properties Outdated Show resolved Hide resolved
import org.apache.spark.sql.vectorized.ColumnVector;
import org.apache.spark.sql.vectorized.ColumnarBatch;

@SuppressWarnings("checkstyle:VisibilityModifier")
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes would require a bit more time to review. I'll do that tomorrow. I think we would want to restructure the original implementation a bit. Not a concern for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

We would want to structure this a bit differently. Let me think more.

@github-actions github-actions bot removed the API label Apr 26, 2024
@huaxingao
Copy link
Contributor Author

@aokolnychyi I have addressed the comments. Could you please take one more look when you have a moment? Thanks a lot!

@aokolnychyi
Copy link
Contributor

Will check today.

import org.apache.spark.sql.vectorized.ColumnVector;
import org.apache.spark.sql.vectorized.ColumnarBatch;

@SuppressWarnings("checkstyle:VisibilityModifier")
Copy link
Contributor

Choose a reason for hiding this comment

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

We would want to structure this a bit differently. Let me think more.

@cornelcreanga
Copy link

@huaxingao - Hi, is the Comet Parquet reader able to support page skipping/use page indexes? -eg see #193 for the Iceberg Parquet reader initial issue.

@huaxingao
Copy link
Contributor Author

@cornelcreanga Comet Parquet reader doesn't support page skipping yet

@huaxingao huaxingao closed this Jun 20, 2024
@huaxingao huaxingao reopened this Jun 20, 2024
@PaulLiang1
Copy link

hey @huaxingao
we are really interested in this feature, just wonder what can we help to getting this integrated?

@huaxingao
Copy link
Contributor Author

@PaulLiang1 Thank you for your interest! We are currently working on a binary release of DataFusion Comet. Once the binary release is available, I will proceed with this PR.

@PaulLiang1
Copy link

@huaxingao
I think we got a internal version of building DataFusion comet and publish a JAR internally.
Is there anything we can help with on that front?

Thanks

@huaxingao
Copy link
Contributor Author

@PaulLiang1 Thanks! I'll check with my colleague tomorrow to find out where we are in the binary release process.

@huaxingao
Copy link
Contributor Author

@PaulLiang1 We are pretty close to this and will have a binary release for Comet soon.

@PaulLiang1
Copy link

@PaulLiang1 Thanks! I'll check with my colleague tomorrow to find out where we are in the binary release process.

got it, thanks for letting me know. please feel free to let us know if there is anything we could help on. thanks!

@findepi
Copy link
Member

findepi commented Oct 3, 2024

that's an interesting proposal for sure!
The PR description very nicely describes the intent of integrating of the Comet, thank you!.
It could be helpful, if it also explained the benefits of doing so.
From #9841 (comment) I infer that the main value driver for the change is performance. With that in sight, would you mind doing some comparative benchmarking between current Iceberg reader, the Comet reader and Trino's Iceberg Reader? It would be good to quantify the gains of going native.

cc @raunaqmorarka @sopel39

@huaxingao
Copy link
Contributor Author

@findepi We have TPCH benchmark results for Parquet files (without iceberg) on the DataFusion Comet website. We are still working on improving performance. We don't have benchmarks for Iceberg yet. We will post the benchmarks once they are available.

@findepi
Copy link
Member

findepi commented Oct 4, 2024

The query-level benchmarks like TPCH aren't needed, I guess. It would good to know how different Parquet reader implementations compare against each other, so that we know what do we gain by embracing native.

@huaxingao
Copy link
Contributor Author

@findepi Comet's Parquet reader is a hybrid implementation: IO and decompression are done in the JVM while decoding is done natively. There is some performance gain from native decoding, but the gain is not substantial. However, by switching to the Comet Parquet reader, Comet will recognize that this is a Comet scan and will convert the Spark physical plan into a Comet plan for native execution. The major performance gain will be from this native execution.

@findepi
Copy link
Member

findepi commented Oct 12, 2024

thanks @huaxingao for this additional explanation. This makes sense. Can you please replicate that information in the PR description as well? thanks!

@github-actions github-actions bot added the INFRA label Oct 21, 2024
@huaxingao
Copy link
Contributor Author

@aokolnychyi We finally have a Comet binary release, and I've updated the PR to use it. Could you please take a look at the PR when you have time? Thanks a lot!

@bmorck
Copy link

bmorck commented Oct 28, 2024

@huaxingao Very interested in this work and thanks a bunch for taking this on! Wanted to see if this PR addresses all changes needed on the iceberg side needed to integrate comet with iceberg. For example do we also need to do things such as

  • Have SparkBatchQueryScan implement the org.apache.comet.parquet.SupportsComet interface?

Wanted to also see if you think this is at a place where we can try to port this change into our iceberg fork? Also wanted to see if there is anything we can do to help out here!

@huaxingao
Copy link
Contributor Author

@bmorck Thanks for your interest! Currently, this PR only enables the CometBatchReader for batch reading; it does not yet turn on Comet's native operators. In the next step, I will make SparkBatchQueryScan implement the SupportsComet interface to enable all of Comet's native operators. I will proceed with the second step as soon as the review is completed.
Yes, you can port this change into your Iceberg fork, or wait a couple of weeks until my second step is complete if you want the native operators to be activated.

Copy link

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Nov 29, 2024
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.

8 participants