-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: mag1c1an1 <[email protected]> bump up prost Signed-off-by: mag1c1an1 <[email protected]> copy from doris Signed-off-by: mag1c1an1 <[email protected]> add c bindings Signed-off-by: mag1c1an1 <[email protected]> add tests Signed-off-by: mag1c1an1 <[email protected]> write interface in java Signed-off-by: mag1c1an1 <[email protected]> interface 0.1.0 Signed-off-by: mag1c1an1 <[email protected]> cargo clippy && cargo fmt Signed-off-by: mag1c1an1 <[email protected]> use try_logger Signed-off-by: mag1c1an1 <[email protected]>
- Loading branch information
Showing
31 changed files
with
1,225 additions
and
234 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
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
59 changes: 59 additions & 0 deletions
59
lakesoul-common/src/main/java/com/dmetasoul/lakesoul/meta/jnr/SplitDesc.java
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,59 @@ | ||
package com.dmetasoul.lakesoul.meta.jnr; | ||
|
||
import com.alibaba.fastjson.annotation.JSONField; | ||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
import org.apache.commons.lang3.builder.ToStringStyle; | ||
|
||
import java.util.List; | ||
|
||
public class SplitDesc { | ||
@JSONField(name = "file_paths") | ||
private List<String> filePaths; | ||
@JSONField(name = "primary_keys") | ||
private List<String> primaryKeys; | ||
@JSONField(name = "partition_desc_array") | ||
private List<String> partitionDescArray; | ||
@JSONField(name = "table_schema") | ||
private String tableSchema; | ||
|
||
public List<String> getFilePaths() { | ||
return filePaths; | ||
} | ||
|
||
public void setFilePaths(List<String> filePaths) { | ||
this.filePaths = filePaths; | ||
} | ||
|
||
public List<String> getPrimaryKeys() { | ||
return primaryKeys; | ||
} | ||
|
||
public void setPrimaryKeys(List<String> primaryKeys) { | ||
this.primaryKeys = primaryKeys; | ||
} | ||
|
||
public List<String> getPartitionDescArray() { | ||
return partitionDescArray; | ||
} | ||
|
||
public void setPartitionDescArray(List<String> partitionDescArray) { | ||
this.partitionDescArray = partitionDescArray; | ||
} | ||
|
||
public String getTableSchema() { | ||
return tableSchema; | ||
} | ||
|
||
public void setTableSchema(String tableSchema) { | ||
this.tableSchema = tableSchema; | ||
} | ||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) | ||
.append("file_paths", filePaths) | ||
.append("primary_keys", primaryKeys) | ||
.append("partition_desc_array", partitionDescArray) | ||
.append("table_schema", tableSchema) | ||
.toString(); | ||
} | ||
} |
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
119 changes: 119 additions & 0 deletions
119
lakesoul-spark/src/test/scala/org/apache/spark/sql/lakesoul/SplitDescSuite.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,119 @@ | ||
package org.apache.spark.sql.lakesoul | ||
|
||
import com.dmetasoul.lakesoul.meta.jnr.NativeMetadataJavaClient | ||
import com.dmetasoul.lakesoul.tables.LakeSoulTable | ||
import org.apache.spark.sql._ | ||
import org.junit.runner.RunWith | ||
import org.scalatest.funsuite.AnyFunSuite | ||
import org.scalatestplus.junit.JUnitRunner | ||
|
||
// TODO scala_test | ||
//object JnrSuite { | ||
// def main(args: Array[String]): Unit = { | ||
// val spark = SparkSession.builder.master("local") | ||
// .config("spark.sql.extensions", "com.dmetasoul.lakesoul.sql.LakeSoulSparkSessionExtension") | ||
// // 使用 SQL 功能还需要增加以下两个配置项 | ||
// .config("spark.sql.catalog.lakesoul", "org.apache.spark.sql.lakesoul.catalog.LakeSoulCatalog") | ||
// .config("spark.sql.defaultCatalog", "lakesoul") | ||
// .getOrCreate() | ||
// import spark.implicits._ | ||
// val df = Seq( | ||
// ("2021-01-01", 1, "rice1"), | ||
// ("2021-01-02", 2, "rice2"), | ||
// ("2021-01-03", 3, "rice3"), | ||
// ("2021-01-04", 4, "rice4"), | ||
// ("2021-01-05", 5, "rice5"), | ||
// ("2021-01-06", 6, "bread"), | ||
// ("2021-01-01", 7, "rice7") | ||
// ).toDF("date", "id", "name") | ||
// val tablePath = "file:///tmp/lakesoul/lakesoul-test-bucket/data" | ||
// //create table | ||
// //spark batch | ||
// df.write | ||
// .mode("append") | ||
// .format("lakesoul") | ||
// .option("rangePartitions", "date") | ||
// .option("hashPartitions", "id") | ||
// .option("hashBucketNum", "2") | ||
// .save(tablePath) | ||
// val descs = NativeMetadataJavaClient.getInstance().createSplitDescArray("", "default"); | ||
// println(descs) | ||
// } | ||
//} | ||
|
||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class JnrSuite extends AnyFunSuite { | ||
test("basic" ) { | ||
val spark = SparkSession.builder.master("local") | ||
.config("spark.sql.extensions", "com.dmetasoul.lakesoul.sql.LakeSoulSparkSessionExtension") | ||
// 使用 SQL 功能还需要增加以下两个配置项 | ||
.config("spark.sql.catalog.lakesoul", "org.apache.spark.sql.lakesoul.catalog.LakeSoulCatalog") | ||
.config("spark.sql.defaultCatalog", "lakesoul") | ||
.config("spark.hadoop.fs.s3.impl","org.apache.hadoop.fs.s3a.S3AFileSystem") | ||
.config("spark.hadoop.fs.s3a.buffer.dir","/tmp/spark") | ||
.config("spark.hadoop.fs.s3a.path.style.access","true") | ||
.config("spark.hadoop.fs.s3a.endpoint","http://localhost:9000") | ||
.config("spark.hadoop.fs.s3a.aws.credentials.provider","org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider") | ||
.getOrCreate() | ||
import spark.implicits._ | ||
val tablePath = "s3://lakesoul-test-bucket/test_table" | ||
val df = Seq(("2021-01-01", 1, "rice"), ("2021-01-01", 2, "bread")).toDF("date", "id", "name") | ||
df.write | ||
.mode("append") | ||
.format("lakesoul") | ||
.option("rangePartitions", "date") | ||
.option("hashPartitions", "id") | ||
.option("hashBucketNum", "2") | ||
.save(tablePath) | ||
println("hello scala test") | ||
} | ||
|
||
test("read") { | ||
val spark = SparkSession.builder.master("local") | ||
.config("spark.sql.extensions", "com.dmetasoul.lakesoul.sql.LakeSoulSparkSessionExtension") | ||
// 使用 SQL 功能还需要增加以下两个配置项 | ||
.config("spark.sql.catalog.lakesoul", "org.apache.spark.sql.lakesoul.catalog.LakeSoulCatalog") | ||
.config("spark.sql.defaultCatalog", "lakesoul") | ||
.config("spark.hadoop.fs.s3.impl","org.apache.hadoop.fs.s3a.S3AFileSystem") | ||
.config("spark.hadoop.fs.s3a.buffer.dir","/tmp/spark") | ||
.config("spark.hadoop.fs.s3a.path.style.access","true") | ||
.config("spark.hadoop.fs.s3a.endpoint","http://localhost:9000") | ||
.config("spark.hadoop.fs.s3a.aws.credentials.provider","org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider") | ||
.getOrCreate() | ||
val tablePath = "s3://lakesoul-test-bucket/test_table" | ||
val df = spark.read.format("lakesoul").load(tablePath) | ||
df.show() | ||
} | ||
|
||
test("delete") { | ||
val spark = SparkSession.builder.master("local") | ||
.config("spark.sql.extensions", "com.dmetasoul.lakesoul.sql.LakeSoulSparkSessionExtension") | ||
// 使用 SQL 功能还需要增加以下两个配置项 | ||
.config("spark.sql.catalog.lakesoul", "org.apache.spark.sql.lakesoul.catalog.LakeSoulCatalog") | ||
.config("spark.sql.defaultCatalog", "lakesoul") | ||
.config("spark.hadoop.fs.s3.impl","org.apache.hadoop.fs.s3a.S3AFileSystem") | ||
.config("spark.hadoop.fs.s3a.buffer.dir","/tmp/spark") | ||
.config("spark.hadoop.fs.s3a.path.style.access","true") | ||
.config("spark.hadoop.fs.s3a.endpoint","http://localhost:9000") | ||
.config("spark.hadoop.fs.s3a.aws.credentials.provider","org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider") | ||
.getOrCreate() | ||
val tablePath = "s3://lakesoul-test-bucket/test_table" | ||
LakeSoulTable.forPath(tablePath).delete() | ||
} | ||
|
||
test("clean bucket") { | ||
val spark = SparkSession.builder.master("local") | ||
.config("spark.sql.extensions", "com.dmetasoul.lakesoul.sql.LakeSoulSparkSessionExtension") | ||
// 使用 SQL 功能还需要增加以下两个配置项 | ||
.config("spark.sql.catalog.lakesoul", "org.apache.spark.sql.lakesoul.catalog.LakeSoulCatalog") | ||
.config("spark.sql.defaultCatalog", "lakesoul") | ||
.config("spark.hadoop.fs.s3.impl","org.apache.hadoop.fs.s3a.S3AFileSystem") | ||
.config("spark.hadoop.fs.s3a.buffer.dir","/tmp/spark") | ||
.config("spark.hadoop.fs.s3a.path.style.access","true") | ||
.config("spark.hadoop.fs.s3a.endpoint","http://localhost:9000") | ||
.config("spark.hadoop.fs.s3a.aws.credentials.provider","org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider") | ||
.getOrCreate() | ||
} | ||
|
||
} |
Oops, something went wrong.