MCPcopy Create free account
hub / github.com/apache/datafusion / infer_schema

Function infer_schema

datafusion/core/src/datasource/file_format/csv.rs:244–290  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

242
243 #[tokio::test]
244 async fn infer_schema() -> Result<()> {
245 let session_ctx = SessionContext::new();
246 let state = session_ctx.state();
247
248 let projection = None;
249 let root = "./tests/data/csv";
250 let format = CsvFormat::default().with_has_header(true);
251 let exec = scan_format(
252 &state,
253 &format,
254 None,
255 root,
256 "aggregate_test_100_with_nulls.csv",
257 projection,
258 None,
259 )
260 .await?;
261
262 let x: Vec<String> = exec
263 .schema()
264 .fields()
265 .iter()
266 .map(|f| format!("{}: {:?}", f.name(), f.data_type()))
267 .collect();
268 assert_eq!(
269 vec![
270 "c1: Utf8",
271 "c2: Int64",
272 "c3: Int64",
273 "c4: Int64",
274 "c5: Int64",
275 "c6: Int64",
276 "c7: Int64",
277 "c8: Int64",
278 "c9: Int64",
279 "c10: Utf8",
280 "c11: Float64",
281 "c12: Float64",
282 "c13: Utf8",
283 "c14: Null",
284 "c15: Utf8"
285 ],
286 x
287 );
288
289 Ok(())
290 }
291
292 #[tokio::test]
293 async fn infer_schema_with_null_regex() -> Result<()> {

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
scan_formatFunction · 0.85
collectMethod · 0.80
stateMethod · 0.45
with_has_headerMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
fieldsMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…