(
&self,
table_ref: impl Into<TableReference>,
table_path: impl AsRef<str>,
ctx: &SessionContext,
)
| 149 | } |
| 150 | |
| 151 | async fn register_data( |
| 152 | &self, |
| 153 | table_ref: impl Into<TableReference>, |
| 154 | table_path: impl AsRef<str>, |
| 155 | ctx: &SessionContext, |
| 156 | ) -> Result<()> { |
| 157 | let csv_options = Default::default(); |
| 158 | let parquet_options = Default::default(); |
| 159 | |
| 160 | let table_path_str = table_path.as_ref(); |
| 161 | |
| 162 | let extension = Path::new(table_path_str) |
| 163 | .extension() |
| 164 | .and_then(|s| s.to_str()) |
| 165 | .unwrap_or(""); |
| 166 | |
| 167 | match extension { |
| 168 | "csv" => { |
| 169 | ctx.register_csv(table_ref, table_path_str, csv_options) |
| 170 | .await |
| 171 | .map_err(|e| { |
| 172 | DataFusionError::Context( |
| 173 | format!("Registering 'table' as {table_path_str}"), |
| 174 | Box::new(e), |
| 175 | ) |
| 176 | }) |
| 177 | .expect("error registering csv"); |
| 178 | } |
| 179 | "parquet" => { |
| 180 | ctx.register_parquet(table_ref, table_path_str, parquet_options) |
| 181 | .await |
| 182 | .map_err(|e| { |
| 183 | DataFusionError::Context( |
| 184 | format!("Registering 'table' as {table_path_str}"), |
| 185 | Box::new(e), |
| 186 | ) |
| 187 | }) |
| 188 | .expect("error registering parquet"); |
| 189 | } |
| 190 | _ => { |
| 191 | return Err(DataFusionError::Plan(format!( |
| 192 | "Unsupported file extension: {extension}", |
| 193 | ))); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | Ok(()) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | pub struct AllQueries { |
no test coverage detected