@@ -10,6 +10,8 @@ import scala.util.Try
10
10
11
11
trait Format {
12
12
13
+ def name : String
14
+
13
15
// Return the primary partitions (based on the 'partitionColumn') filtered down by sub-partition filters if provided
14
16
// If subpartition filters are supplied and the format doesn't support it, we throw an error
15
17
def primaryPartitions (tableName : String ,
@@ -45,6 +47,7 @@ trait Format {
45
47
46
48
// Does this format support sub partitions filters
47
49
def supportSubPartitionsFilter : Boolean
50
+
48
51
}
49
52
50
53
/**
@@ -58,6 +61,8 @@ trait FormatProvider extends Serializable {
58
61
def sparkSession : SparkSession
59
62
def readFormat (tableName : String ): Format
60
63
def writeFormat (tableName : String ): Format
64
+
65
+ def resolveTableName (tableName : String ) = tableName
61
66
}
62
67
63
68
/**
@@ -134,6 +139,8 @@ case class DefaultFormatProvider(sparkSession: SparkSession) extends FormatProvi
134
139
}
135
140
136
141
case object Hive extends Format {
142
+
143
+ override def name : String = " hive"
137
144
override def primaryPartitions (tableName : String , partitionColumn : String , subPartitionsFilter : Map [String , String ])(
138
145
implicit sparkSession : SparkSession ): Seq [String ] =
139
146
super .primaryPartitions(tableName, partitionColumn, subPartitionsFilter)
@@ -167,6 +174,8 @@ case object Hive extends Format {
167
174
}
168
175
169
176
case object Iceberg extends Format {
177
+
178
+ override def name : String = " iceberg"
170
179
override def primaryPartitions (tableName : String , partitionColumn : String , subPartitionsFilter : Map [String , String ])(
171
180
implicit sparkSession : SparkSession ): Seq [String ] = {
172
181
if (! supportSubPartitionsFilter && subPartitionsFilter.nonEmpty) {
@@ -216,6 +225,8 @@ case object Iceberg extends Format {
216
225
// In such cases, you should implement your own FormatProvider built on the newer Delta lake version
217
226
case object DeltaLake extends Format {
218
227
228
+ override def name : String = " delta"
229
+
219
230
override def primaryPartitions (tableName : String , partitionColumn : String , subPartitionsFilter : Map [String , String ])(
220
231
implicit sparkSession : SparkSession ): Seq [String ] =
221
232
super .primaryPartitions(tableName, partitionColumn, subPartitionsFilter)
0 commit comments