File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def import_table(path: str,
16
16
Import tsv file as Spark DataFrame.
17
17
18
18
:param path: File path
19
- :param header:
19
+ :param header: True if the first row is header.
20
20
:param sep: Column separator
21
21
:param n_partitions: Minimal number of partitions
22
22
@@ -39,6 +39,31 @@ def import_table(path: str,
39
39
return sdf
40
40
41
41
42
+ def import_parquet (path : str ,
43
+ header : bool = True ) -> pyspark .sql .DataFrame :
44
+ """
45
+ Import parquet file as Spark DataFrame.
46
+
47
+ :param path: File path
48
+ :param header: True if the first row is header.
49
+
50
+ :return: Spark DataFrame
51
+ """
52
+
53
+ _sc = pyspark .sql .SparkSession .getActiveSession ()
54
+
55
+ if _sc is None :
56
+ raise ValueError ("Active Spark Session not found..." )
57
+
58
+ sdf = (_sc
59
+ .read
60
+ .option ("header" , header )
61
+ .option ("inferSchema" , "true" )
62
+ .parquet (path )
63
+ )
64
+ return sdf
65
+
66
+
42
67
def import_table_as_psdf (path : str ,
43
68
sep : str = "\t " ,
44
69
n_partitions : int = 5 ) -> pyspark .pandas .DataFrame :
You can’t perform that action at this time.
0 commit comments