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

build: Enable comet tests with spark-4.0 profile #493

Merged
merged 47 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a1fff9b
build: Add spark-4.0 profile
kazuyukitanimura Apr 30, 2024
465b828
build: Add spark-4.0 profile
kazuyukitanimura May 1, 2024
62b7d2f
build: Add spark-4.0 profile
kazuyukitanimura May 7, 2024
8db78cb
build: Add spark-4.0 profile
kazuyukitanimura May 7, 2024
02a970a
Merge remote-tracking branch 'upstream/main' into spark-4.0
kazuyukitanimura May 7, 2024
7251eb2
build: Add spark-4.0 profile
kazuyukitanimura May 8, 2024
17a6995
build: Add spark-4.0 profile
kazuyukitanimura May 8, 2024
57d6538
build: Add spark-4.0 profile
kazuyukitanimura May 8, 2024
d3efeb8
build: Add spark-4.0 profile
kazuyukitanimura May 8, 2024
e310eb1
Merge remote-tracking branch 'upstream/main' into spark-4.0
kazuyukitanimura May 9, 2024
69ca228
build: Add spark-4.0 profile and shims
kazuyukitanimura May 9, 2024
3aec9e6
build: Add spark-4.0 profile and shims
kazuyukitanimura May 9, 2024
d629df1
build: Add spark-4.0 profile and shims
kazuyukitanimura May 9, 2024
65628fb
build: Add spark-4.0 profile and shims
kazuyukitanimura May 10, 2024
328705f
build: Add spark-4.0 profile and shims
kazuyukitanimura May 11, 2024
b85c712
build: Add spark-4.0 profile and shims
kazuyukitanimura May 11, 2024
8dc9dba
build: Add spark-4.0 profile and shims
kazuyukitanimura May 11, 2024
9a4b605
build: Add spark-4.0 profile and shims
kazuyukitanimura May 11, 2024
8ec2767
build: Enable spark-4.0 tests
kazuyukitanimura May 14, 2024
396d077
address review comments
kazuyukitanimura May 15, 2024
b819e99
address review comments
kazuyukitanimura May 15, 2024
728bf8d
build: Enable spark-4.0 tests
kazuyukitanimura May 15, 2024
8374f74
build: Enable spark-4.0 tests
kazuyukitanimura May 15, 2024
a4d050b
build: Enable spark-4.0 tests
kazuyukitanimura May 15, 2024
0cd4870
address review comments
kazuyukitanimura May 16, 2024
f91c7be
address review comments
kazuyukitanimura May 16, 2024
c146661
build: Enable spark-4.0 tests
kazuyukitanimura May 16, 2024
8c4bf05
DisableSuite
kazuyukitanimura May 16, 2024
225858f
build: Enable spark-4.0 tests
kazuyukitanimura May 17, 2024
f472ee3
Merge remote-tracking branch 'upstream/main' into spark-4.0
kazuyukitanimura May 17, 2024
1cb96dc
Merge branch 'spark-4.0' into spark-4.0-test
kazuyukitanimura May 17, 2024
7911e52
build: Enable spark-4.0 tests
kazuyukitanimura May 17, 2024
e258273
build: Enable spark-4.0 tests
kazuyukitanimura May 17, 2024
c1fd154
build: Enable spark-4.0 tests
kazuyukitanimura May 17, 2024
80a292b
build: Enable spark-4.0 tests
kazuyukitanimura May 17, 2024
5999156
Merge remote-tracking branch 'upstream/main' into spark-4.0-test
kazuyukitanimura May 20, 2024
3335e4d
address review comments
kazuyukitanimura May 20, 2024
f0f8b0c
address review comments
kazuyukitanimura May 21, 2024
f5aa2b4
build: Enable spark-4.0 tests
kazuyukitanimura May 21, 2024
be4c367
Merge remote-tracking branch 'upstream/main' into spark-4.0-test
kazuyukitanimura May 21, 2024
1910927
build: Enable spark-4.0 tests
kazuyukitanimura May 21, 2024
443bee8
address review comments
kazuyukitanimura May 22, 2024
8036660
address review comments
kazuyukitanimura May 23, 2024
d388d4b
Merge remote-tracking branch 'upstream/main' into spark-4.0-test
kazuyukitanimura May 24, 2024
46bddfa
build: Enable spark-4.0 tests
kazuyukitanimura May 24, 2024
1a8939f
Merge remote-tracking branch 'upstream/main' into spark-4.0-test
kazuyukitanimura May 28, 2024
53fd09c
address review comments
kazuyukitanimura May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ jobs:
- name: Java test steps
uses: ./.github/actions/java-test
with:
# TODO: remove -DskipTests after fixing tests
maven_opts: "-Pspark-${{ matrix.spark-version }} -DskipTests"
# TODO: upload test reports after enabling tests
upload-test-reports: false
maven_opts: -Pspark-${{ matrix.spark-version }}
upload-test-reports: true

linux-test-with-old-spark:
strategy:
Expand Down Expand Up @@ -237,10 +235,8 @@ jobs:
- name: Java test steps
uses: ./.github/actions/java-test
with:
# TODO: remove -DskipTests after fixing tests
maven_opts: "-Pspark-${{ matrix.spark-version }} -DskipTests"
# TODO: upload test reports after enabling tests
upload-test-reports: false
maven_opts: -Pspark-${{ matrix.spark-version }}
upload-test-reports: true

macos-aarch64-test-with-spark4_0:
strategy:
Expand Down Expand Up @@ -277,10 +273,8 @@ jobs:
- name: Java test steps
uses: ./.github/actions/java-test
with:
# TODO: remove -DskipTests after fixing tests
maven_opts: "-Pspark-${{ matrix.spark-version }} -DskipTests"
# TODO: upload test reports after enabling tests
upload-test-reports: false
maven_opts: -Pspark-${{ matrix.spark-version }}
upload-test-reports: true

macos-aarch64-test-with-old-spark:
strategy:
Expand Down
9 changes: 6 additions & 3 deletions common/src/main/scala/org/apache/comet/CometConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import org.apache.spark.network.util.JavaUtils
import org.apache.spark.sql.comet.util.Utils
import org.apache.spark.sql.internal.SQLConf

import org.apache.comet.shims.ShimCometConf

/**
* Configurations for a Comet application. Mostly inspired by [[SQLConf]] in Spark.
*
Expand All @@ -41,7 +43,7 @@ import org.apache.spark.sql.internal.SQLConf
* which retrieves the config value from the thread-local [[SQLConf]] object. Alternatively, you
* can also explicitly pass a [[SQLConf]] object to the `get` method.
*/
object CometConf {
object CometConf extends ShimCometConf {

/** List of all configs that is used for generating documentation */
val allConfs = new ListBuffer[ConfigEntry[_]]
Expand Down Expand Up @@ -361,7 +363,7 @@ object CometConf {
"column to a long column, a float column to a double column, etc. This is automatically" +
"enabled when reading from Iceberg tables.")
.booleanConf
.createWithDefault(false)
.createWithDefault(COMET_SCHEMA_EVOLUTION_ENABLED_DEFAULT)

val COMET_ROW_TO_COLUMNAR_ENABLED: ConfigEntry[Boolean] =
conf("spark.comet.rowToColumnar.enabled")
Expand All @@ -382,12 +384,13 @@ object CometConf {
.createWithDefault(Seq("Range,InMemoryTableScan"))

val COMET_ANSI_MODE_ENABLED: ConfigEntry[Boolean] = conf("spark.comet.ansi.enabled")
.internal()
Copy link
Member

Choose a reason for hiding this comment

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

Why making it internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed in #493 (comment)
doc is not per profile yet. By making it internal, doc will ignore it.

.doc(
"Comet does not respect ANSI mode in most cases and by default will not accelerate " +
"queries when ansi mode is enabled. Enable this setting to test Comet's experimental " +
"support for ANSI mode. This should not be used in production.")
.booleanConf
.createWithDefault(false)
.createWithDefault(COMET_ANSI_MODE_ENABLED_DEFAULT)
Comment on lines +387 to +393
Copy link
Member

Choose a reason for hiding this comment

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

We may need to mention it is enabled by default for Spark 4.0 now. It could produce incorrect results so we better don't make it implicitly enabled.

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, Spark 4.0 support is not ready at all. I will send follow up PRs


val COMET_CAST_ALLOW_INCOMPATIBLE: ConfigEntry[Boolean] =
conf("spark.comet.cast.allowIncompatible")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.comet.shims

trait ShimCometConf {
protected val COMET_SCHEMA_EVOLUTION_ENABLED_DEFAULT = false
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: do we need a trailing _DEFAULT in the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would say so as we have COMET_SCHEMA_EVOLUTION_ENABLED in conf. Also this is default so that users can overwrite.

protected val COMET_ANSI_MODE_ENABLED_DEFAULT = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.comet.shims

trait ShimCometConf {
protected val COMET_SCHEMA_EVOLUTION_ENABLED_DEFAULT = true
protected val COMET_ANSI_MODE_ENABLED_DEFAULT = true
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to enable this by default when we know that we are not compatible yet?

Copy link
Member

Choose a reason for hiding this comment

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

I suppose we have to do this otherwise all plans will currently fall back to Spark because ANSI mode is enabled by default in Spark 4.

We should really only fall back to Spark for expressions that are actually affected by ANSI support rather than fall back for everything.

Perhaps we could add a note to the documentation explaining that ANSI mode in Spark 4 is not fully compatible yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am thinking to use Spark-4.0 as a test bed for ANSI readiness. I will send another PR for enabling Spark tests and if I find any incompatibility, I will disable them per function.

Copy link
Member

Choose a reason for hiding this comment

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

You need it to be enabled for Spark tests, isn't?

Copy link
Member

Choose a reason for hiding this comment

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

Also see #509 to allow us to fall back per function if ANSI is not supported yet and #313 where we are tracking all ANSI work

}
4 changes: 4 additions & 0 deletions docs/source/contributor-guide/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,27 @@ The plan stability testing framework is located in the `spark` module and can be

```sh
./mvnw -pl spark -Dsuites="org.apache.spark.sql.comet.CometTPCDSV1_4_PlanStabilitySuite" test
./mvnw -pl spark -Dsuites="org.apache.spark.sql.comet.CometTPCDSV1_4_PlanStabilitySuite" -Pspark-4.0 -nsu test
```

and
```sh
./mvnw -pl spark -Dsuites="org.apache.spark.sql.comet.CometTPCDSV2_7_PlanStabilitySuite" test
./mvnw -pl spark -Dsuites="org.apache.spark.sql.comet.CometTPCDSV2_7_PlanStabilitySuite" -Pspark-4.0 -nsu test
```

If your pull request changes the query plans generated by Comet, you should regenerate the golden files.
To regenerate the golden files, you can run the following command:

```sh
SPARK_GENERATE_GOLDEN_FILES=1 ./mvnw -pl spark -Dsuites="org.apache.spark.sql.comet.CometTPCDSV1_4_PlanStabilitySuite" test
SPARK_GENERATE_GOLDEN_FILES=1 ./mvnw -pl spark -Dsuites="org.apache.spark.sql.comet.CometTPCDSV1_4_PlanStabilitySuite" -Pspark-4.0 -nsu test
```

and
```sh
SPARK_GENERATE_GOLDEN_FILES=1 ./mvnw -pl spark -Dsuites="org.apache.spark.sql.comet.CometTPCDSV2_7_PlanStabilitySuite" test
SPARK_GENERATE_GOLDEN_FILES=1 ./mvnw -pl spark -Dsuites="org.apache.spark.sql.comet.CometTPCDSV2_7_PlanStabilitySuite" -Pspark-4.0 -nsu test
```

## Benchmark
Expand Down
1 change: 0 additions & 1 deletion docs/source/user-guide/configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Comet provides the following configuration settings.

| Config | Description | Default Value |
|--------|-------------|---------------|
| spark.comet.ansi.enabled | Comet does not respect ANSI mode in most cases and by default will not accelerate queries when ansi mode is enabled. Enable this setting to test Comet's experimental support for ANSI mode. This should not be used in production. | false |
Copy link
Member

Choose a reason for hiding this comment

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

This highlights that our configs vary depending on the version we build against and we currently only publish one version of our configs.

Ideally we should generate configs per spark version and publish all of them.

Copy link
Member

Choose a reason for hiding this comment

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

I will file an issue for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I plan to associate this config with spark.sql.ansi.enabled. So when Spark enables ANSI, so does Comet

| spark.comet.batchSize | The columnar batch size, i.e., the maximum number of rows that a batch can contain. | 8192 |
| spark.comet.cast.allowIncompatible | Comet is not currently fully compatible with Spark for all cast operations. Set this config to true to allow them anyway. See compatibility guide for more information. | false |
| spark.comet.columnar.shuffle.async.enabled | Whether to enable asynchronous shuffle for Arrow-based shuffle. By default, this config is false. | false |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,10 @@ object CometSparkSessionExtensions extends Logging {
org.apache.spark.SPARK_VERSION >= "3.4"
}

def isSpark40Plus: Boolean = {
org.apache.spark.SPARK_VERSION >= "4.0"
}

/** Calculates required memory overhead in MB per executor process for Comet. */
def getCometMemoryOverheadInMiB(sparkConf: SparkConf): Long = {
// `spark.executor.memory` default value is 1g
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,8 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim
}

def nullIfWhenPrimitive(expression: Expression): Expression = if (isPrimitive(expression)) {
new NullIf(expression, Literal.default(expression.dataType)).child
val zero = Literal.default(expression.dataType)
If(EqualTo(expression, zero), Literal.create(null, expression.dataType), expression)
Comment on lines +2204 to +2205
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NullIf implementation was changed to use With that Comet does not support apache/spark#43623

} else {
expression
}
Expand Down
Loading
Loading