Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.paimon.spark.sql

import org.apache.paimon.CoreOptions
import org.apache.paimon.catalog.Identifier
import org.apache.paimon.data.{GenericRow, Timestamp}
import org.apache.paimon.partition.PartitionStatistics
Expand Down Expand Up @@ -391,23 +392,34 @@ class PaimonPartitionManagementTest extends PaimonSparkTestBase {
}
}

test("Paimon Partition Management: address the null partition by NULL, not its default name") {
withTable("T") {
spark.sql("CREATE TABLE T (a INT, p1 STRING, p2 STRING) PARTITIONED BY (p1, p2)")
spark.sql("INSERT INTO T VALUES (1, NULL, 'x'), (2, 'b', 'x')")
val truncate = intercept[IllegalArgumentException] {
spark.sql("TRUNCATE TABLE T PARTITION (p1 = '__DEFAULT_PARTITION__', p2 = 'x')")
}
assert(truncate.getMessage.contains("use p1 = NULL"))
val drop = intercept[IllegalArgumentException] {
spark.sql("ALTER TABLE T DROP PARTITION (p1 = '__DEFAULT_PARTITION__')")
}
assert(drop.getMessage.contains("use p1 = NULL"))
checkAnswer(spark.sql("SELECT a FROM T"), Row(1) :: Row(2) :: Nil)
Seq(None, Some("__CUSTOM_NULL_PARTITION__")).foreach {
configuredDefaultName =>
test(
s"Paimon Partition Management: address the null partition by NULL " +
s"(${configuredDefaultName.getOrElse("default")})") {
withTable("T") {
val properties = configuredDefaultName
.map(value => s"TBLPROPERTIES ('partition.default-name' = '$value')")
.getOrElse("")
spark.sql(
s"CREATE TABLE T (a INT, p1 STRING, p2 STRING) PARTITIONED BY (p1, p2) $properties")
spark.sql("INSERT INTO T VALUES (1, NULL, 'x'), (2, 'b', 'x')")
val defaultPartitionName =
CoreOptions.fromMap(loadTable("T").options()).partitionDefaultName()
val truncate = intercept[IllegalArgumentException] {
spark.sql(s"TRUNCATE TABLE T PARTITION (p1 = '$defaultPartitionName', p2 = 'x')")
}
assert(truncate.getMessage.contains("use p1 = NULL"))
val drop = intercept[IllegalArgumentException] {
spark.sql(s"ALTER TABLE T DROP PARTITION (p1 = '$defaultPartitionName')")
}
assert(drop.getMessage.contains("use p1 = NULL"))
checkAnswer(spark.sql("SELECT a FROM T"), Row(1) :: Row(2) :: Nil)

spark.sql("ALTER TABLE T DROP PARTITION (p1 = NULL)")
checkAnswer(spark.sql("SELECT a FROM T"), Row(2) :: Nil)
}
spark.sql("ALTER TABLE T DROP PARTITION (p1 = NULL)")
checkAnswer(spark.sql("SELECT a FROM T"), Row(2) :: Nil)
}
}
}

Seq("BINARY", "STRING").foreach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class VectorSearchOptionsTest extends PaimonSparkTestBase {
val searchTable = spy(table)
when(searchTable.latestSnapshot()).thenReturn(Optional.of(rankedSnapshot))
val vector = Array(1.0f, 0.0f)
val query = """{"match":{"column":"content","terms":"paimon"}}"""
val query = """{"match":{"query":"paimon"}}"""
val scan = PaimonScan(
searchTable,
new StructType().add("id", "int"),
Expand Down
Loading