Skip to content

Commit 3640599

Browse files
committed
update format
1 parent 7ca3892 commit 3640599

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spark/src/main/scala/ai/chronon/spark/Format.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import scala.util.Try
1010

1111
trait Format {
1212

13+
def name: String
14+
1315
// Return the primary partitions (based on the 'partitionColumn') filtered down by sub-partition filters if provided
1416
// If subpartition filters are supplied and the format doesn't support it, we throw an error
1517
def primaryPartitions(tableName: String,
@@ -45,6 +47,7 @@ trait Format {
4547

4648
// Does this format support sub partitions filters
4749
def supportSubPartitionsFilter: Boolean
50+
4851
}
4952

5053
/**
@@ -58,6 +61,8 @@ trait FormatProvider extends Serializable {
5861
def sparkSession: SparkSession
5962
def readFormat(tableName: String): Format
6063
def writeFormat(tableName: String): Format
64+
65+
def resolveTableName(tableName: String) = tableName
6166
}
6267

6368
/**
@@ -134,6 +139,8 @@ case class DefaultFormatProvider(sparkSession: SparkSession) extends FormatProvi
134139
}
135140

136141
case object Hive extends Format {
142+
143+
override def name: String = "hive"
137144
override def primaryPartitions(tableName: String, partitionColumn: String, subPartitionsFilter: Map[String, String])(
138145
implicit sparkSession: SparkSession): Seq[String] =
139146
super.primaryPartitions(tableName, partitionColumn, subPartitionsFilter)
@@ -167,6 +174,8 @@ case object Hive extends Format {
167174
}
168175

169176
case object Iceberg extends Format {
177+
178+
override def name: String = "iceberg"
170179
override def primaryPartitions(tableName: String, partitionColumn: String, subPartitionsFilter: Map[String, String])(
171180
implicit sparkSession: SparkSession): Seq[String] = {
172181
if (!supportSubPartitionsFilter && subPartitionsFilter.nonEmpty) {
@@ -216,6 +225,8 @@ case object Iceberg extends Format {
216225
// In such cases, you should implement your own FormatProvider built on the newer Delta lake version
217226
case object DeltaLake extends Format {
218227

228+
override def name: String = "delta"
229+
219230
override def primaryPartitions(tableName: String, partitionColumn: String, subPartitionsFilter: Map[String, String])(
220231
implicit sparkSession: SparkSession): Seq[String] =
221232
super.primaryPartitions(tableName, partitionColumn, subPartitionsFilter)

0 commit comments

Comments
 (0)