spark_session
Module that manages the spark session.
SPARK_WRITING_MODES
Enum class to define writing modes for spark
Source code in multimno/core/spark_session.py
20 21 22 23 24 25 26 |
|
check_if_data_path_exists(spark, data_path)
Checks whether data path exists, returns True if it does, False if not
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark
|
SparkSession
|
active SparkSession |
required |
data_path
|
str
|
path to check |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Whether the passed path exists |
Source code in multimno/core/spark_session.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
check_or_create_data_path(spark, data_path)
Create the provided path on a file system. If path already exists, do nothing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark
|
SparkSession
|
active SparkSession |
required |
data_path
|
str
|
path to check |
required |
Source code in multimno/core/spark_session.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
delete_file_or_folder(spark, data_path)
Deletes file or folder with given path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark
|
SparkSession
|
Currently active spark session |
required |
data_path
|
str
|
Path to remove |
required |
Source code in multimno/core/spark_session.py
98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
generate_spark_session(config)
Function that generates a Spark Sedona session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
ConfigParser
|
Object with the final configuration. |
required |
Returns:
Name | Type | Description |
---|---|---|
SparkSession |
SparkSession
|
Session of spark. |
Source code in multimno/core/spark_session.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
list_all_files_helper(path, fs, conf)
This function is used by list_all_files_recursively. This should not be called elsewhere Recursively traverses the file tree from given spot saving all files to a list and returns it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
py4j.java_gateway.JavaObject: Object from parent function |
required |
fs
|
JavaClass
|
Object from parent function |
required |
conf
|
JavaObject
|
Object from parent function |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
List[str]
|
List of all files this folder and subdirectories of this folder. |
Source code in multimno/core/spark_session.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
list_all_files_recursively(spark, data_path)
If path is a file, returns a singleton list with this path. If path is a folder, return a list of all files in this folder and any of its subfolders
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark
|
SparkSession
|
Currently active spark session |
required |
data_path
|
str
|
Path to list the files of |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: A list of all files in that folder and its subfolders |
Source code in multimno/core/spark_session.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
list_parquet_partition_col_values(spark, data_path)
Lists all partition column values given a partition parquet folder
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark
|
SparkSession
|
Currently active spark session |
required |
data_path
|
str
|
Path of parquet |
required |
Returns:
Type | Description |
---|---|
List[str]
|
str, List[str]: Name of partition column, List of partition col values |
Source code in multimno/core/spark_session.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|