-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Gluten-core][Vl] supports DeltaLake2.2 read
- Loading branch information
mokunhua
authored and
寻径
committed
Oct 11, 2023
1 parent
8b39625
commit 403eb40
Showing
6 changed files
with
222 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
79 changes: 79 additions & 0 deletions
79
backends-velox/src/test/scala/io/glutenproject/execution/VeloxDeltaSuite.scala
This file contains 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,79 @@ | ||
/* | ||
* 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 io.glutenproject.execution | ||
|
||
import org.apache.spark.SparkConf | ||
import org.apache.spark.sql.Row | ||
|
||
import java.io.File | ||
|
||
class VeloxDeltaSuite extends WholeStageTransformerSuite { | ||
|
||
protected val rootPath: String = getClass.getResource("/").getPath | ||
override protected val backend: String = "velox" | ||
override protected val resourcePath: String = "/tpch-data-parquet-velox" | ||
override protected val fileFormat: String = "parquet" | ||
|
||
override protected def sparkConf: SparkConf = { | ||
super.sparkConf | ||
.set("spark.shuffle.manager", "org.apache.spark.shuffle.sort.ColumnarShuffleManager") | ||
.set("spark.sql.files.maxPartitionBytes", "1g") | ||
.set("spark.sql.shuffle.partitions", "1") | ||
.set("spark.memory.offHeap.size", "2g") | ||
.set("spark.unsafe.exceptionOnMemoryLeak", "true") | ||
.set("spark.sql.autoBroadcastJoinThreshold", "-1") | ||
.set("spark.sql.sources.useV1SourceList", "avro") | ||
.set("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension") | ||
.set("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog") | ||
} | ||
|
||
test("column mapping mode") { | ||
spark.sql(s""" | ||
|create table delta_cm1 (id int, name string) using delta | ||
|tblproperties ("delta.columnMapping.mode"= "id") | ||
|""".stripMargin) | ||
spark.sql(s""" | ||
|insert into delta_cm1 values (1, "v1"), (2, "v2") | ||
|""".stripMargin) | ||
val df1 = runQueryAndCompare("select * from delta_cm1") { _ => } | ||
checkLengthAndPlan(df1, 2) | ||
checkAnswer(df1, Row(1, "v1") :: Row(2, "v2") :: Nil) | ||
|
||
val df2 = runQueryAndCompare("select name from delta_cm1 where id = 2") { _ => } | ||
checkLengthAndPlan(df2, 1) | ||
checkAnswer(df2, Row("v2") :: Nil) | ||
} | ||
} | ||
|
||
class VeloxTPCHDeltaSuite extends VeloxTPCHSuite { | ||
override protected def sparkConf: SparkConf = { | ||
super.sparkConf | ||
.set("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension") | ||
.set("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog") | ||
} | ||
|
||
override protected def createTPCHNotNullTables(): Unit = { | ||
TPCHTables = TPCHTableNames.map { | ||
table => | ||
val tableDir = getClass.getResource(resourcePath).getFile | ||
val tablePath = new File(tableDir, table).getAbsolutePath | ||
val tableDF = spark.read.format(fileFormat).load(tablePath) | ||
tableDF.write.format("delta").mode("append").saveAsTable(table) | ||
(table, tableDF) | ||
}.toMap | ||
} | ||
} |
This file contains 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 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 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 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