Last active
January 29, 2021 19:04
-
-
Save izeigerman/c1c16508c52f306a7aadc4589bd69a5b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import org.apache.spark.sql.SparkSession | |
| trait DataSource[D, P] { | |
| def read(parameters: P)(implicit spark: SparkSession): AnnotatedDataFrame[D] | |
| } | |
| object DataSource { | |
| def apply[D]: Helper[D] = new Helper[D] | |
| // Helper used to improve the type inference and make the reading API cleaner. | |
| final class Helper[D] { | |
| def read[P](parameters: P)(implicit S: DataSource[D, P], spark: SparkSession) = | |
| S.read(parameters) | |
| def read(implicit S: DataSource[D, Unit], spark: SparkSession) = | |
| S.read(()) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment