-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-37377][SQL] Initial implementation of Storage-Partitioned Join #35657
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
deba883
initial commit
sunchao a756538
handle PartitionCollection
sunchao 6beb8b1
add tests for dynamic filtering and fix a bug
sunchao df37703
add one more test when fun catalog is not present
sunchao 93a9152
address comments
sunchao 269e2c5
rebase
sunchao e825b8b
address comments
sunchao 269e836
address comments and fix a bug
sunchao 29330bf
address comments
sunchao 3863b2f
address comments
sunchao c0bfe73
address comments
sunchao de1972b
remove unused import
sunchao 6c545e6
fix test case
sunchao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
...catalyst/src/main/java/org/apache/spark/sql/connector/read/partitioning/Distribution.java
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
...rc/main/java/org/apache/spark/sql/connector/read/partitioning/KeyGroupedPartitioning.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * 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.spark.sql.connector.read.partitioning; | ||
|
|
||
| import org.apache.spark.annotation.Evolving; | ||
| import org.apache.spark.sql.connector.expressions.Expression; | ||
|
|
||
| /** | ||
| * Represents a partitioning where rows are split across partitions based on the | ||
| * partition transform expressions returned by {@link KeyGroupedPartitioning#keys}. | ||
| * <p> | ||
| * Note: Data source implementations should make sure for a single partition, all of its rows | ||
| * must be evaluated to the same partition value after being applied by | ||
| * {@link KeyGroupedPartitioning#keys} expressions. Different partitions can share the same | ||
| * partition value: Spark will group these into a single logical partition during planning phase. | ||
| * | ||
| * @since 3.3.0 | ||
| */ | ||
| @Evolving | ||
| public class KeyGroupedPartitioning implements Partitioning { | ||
| private final Expression[] keys; | ||
| private final int numPartitions; | ||
|
|
||
| public KeyGroupedPartitioning(Expression[] keys, int numPartitions) { | ||
| this.keys = keys; | ||
| this.numPartitions = numPartitions; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the partition transform expressions for this partitioning. | ||
| */ | ||
| public Expression[] keys() { | ||
| return keys; | ||
| } | ||
|
|
||
| @Override | ||
| public int numPartitions() { | ||
| return numPartitions; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
sql/catalyst/src/main/scala-2.12/org/apache/spark/sql/catalyst/util/InternalRowSet.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * 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.spark.sql.catalyst.util | ||
|
|
||
| import scala.collection.mutable | ||
|
|
||
| import org.apache.spark.sql.catalyst.InternalRow | ||
| import org.apache.spark.sql.catalyst.expressions.{Murmur3HashFunction, RowOrdering} | ||
| import org.apache.spark.sql.types.{DataType, StructField, StructType} | ||
|
|
||
| /** | ||
| * A mutable Set with [[InternalRow]] as its element type. It uses Spark's internal murmur hash to | ||
| * compute hash code from an row, and uses [[RowOrdering]] to perform equality checks. | ||
| * | ||
| * @param dataTypes the data types for the row keys this set holds | ||
| */ | ||
| class InternalRowSet(val dataTypes: Seq[DataType]) extends mutable.Set[InternalRow] { | ||
| private val baseSet = new mutable.HashSet[InternalRowContainer] | ||
|
|
||
| private val structType = StructType(dataTypes.map(t => StructField("f", t))) | ||
| private val ordering = RowOrdering.createNaturalAscendingOrdering(dataTypes) | ||
|
|
||
| override def contains(row: InternalRow): Boolean = | ||
| baseSet.contains(new InternalRowContainer(row)) | ||
|
|
||
| private class InternalRowContainer(val row: InternalRow) { | ||
| override def hashCode(): Int = Murmur3HashFunction.hash(row, structType, 42L).toInt | ||
|
|
||
| override def equals(other: Any): Boolean = other match { | ||
| case r: InternalRowContainer => ordering.compare(row, r.row) == 0 | ||
| case r => this == r | ||
| } | ||
| } | ||
|
|
||
| override def +=(row: InternalRow): InternalRowSet.this.type = { | ||
| val rowKey = new InternalRowContainer(row) | ||
| baseSet += rowKey | ||
| this | ||
| } | ||
|
|
||
| override def -=(row: InternalRow): InternalRowSet.this.type = { | ||
| val rowKey = new InternalRowContainer(row) | ||
| baseSet -= rowKey | ||
| this | ||
| } | ||
|
|
||
| override def iterator: Iterator[InternalRow] = { | ||
| baseSet.iterator.map(_.row) | ||
| } | ||
| } | ||
69 changes: 69 additions & 0 deletions
69
sql/catalyst/src/main/scala-2.13/org/apache/spark/sql/catalyst/util/InternalRowSet.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * 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.spark.sql.catalyst.util | ||
|
|
||
| import scala.collection.mutable | ||
|
|
||
| import org.apache.spark.sql.catalyst.InternalRow | ||
| import org.apache.spark.sql.catalyst.expressions.{Murmur3HashFunction, RowOrdering} | ||
| import org.apache.spark.sql.types.{DataType, StructField, StructType} | ||
|
|
||
| /** | ||
| * A mutable Set with [[InternalRow]] as its element type. It uses Spark's internal murmur hash to | ||
| * compute hash code from an row, and uses [[RowOrdering]] to perform equality checks. | ||
| * | ||
| * @param dataTypes the data types for the row keys this set holds | ||
| */ | ||
| class InternalRowSet(val dataTypes: Seq[DataType]) extends mutable.Set[InternalRow] { | ||
| private val baseSet = new mutable.HashSet[InternalRowContainer] | ||
|
|
||
| private val structType = StructType(dataTypes.map(t => StructField("f", t))) | ||
| private val ordering = RowOrdering.createNaturalAscendingOrdering(dataTypes) | ||
|
|
||
| override def contains(row: InternalRow): Boolean = | ||
| baseSet.contains(new InternalRowContainer(row)) | ||
|
|
||
| private class InternalRowContainer(val row: InternalRow) { | ||
| override def hashCode(): Int = Murmur3HashFunction.hash(row, structType, 42L).toInt | ||
|
|
||
| override def equals(other: Any): Boolean = other match { | ||
| case r: InternalRowContainer => ordering.compare(row, r.row) == 0 | ||
| case r => this == r | ||
| } | ||
| } | ||
|
|
||
| override def addOne(row: InternalRow): InternalRowSet.this.type = { | ||
| val rowKey = new InternalRowContainer(row) | ||
| baseSet += rowKey | ||
| this | ||
| } | ||
|
|
||
| override def subtractOne(row: InternalRow): InternalRowSet.this.type = { | ||
| val rowKey = new InternalRowContainer(row) | ||
| baseSet -= rowKey | ||
| this | ||
| } | ||
|
|
||
| override def clear(): Unit = { | ||
| baseSet.clear() | ||
| } | ||
|
|
||
| override def iterator: Iterator[InternalRow] = { | ||
| baseSet.iterator.map(_.row) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.