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

Function test_form_identifier

datafusion/sql/src/expr/identifier.rs:476–522  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

474
475 #[test]
476 fn test_form_identifier() -> Result<()> {
477 let err = form_identifier(&[]).expect_err("empty identifiers didn't fail");
478 let expected = "Internal error: Incorrect number of identifiers: 0.\n\
479 This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this \
480 by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues";
481 assert!(expected.starts_with(&err.strip_backtrace()));
482
483 let ids = vec!["a".to_string()];
484 let (qualifier, column) = form_identifier(&ids)?;
485 assert_eq!(qualifier, None);
486 assert_eq!(column, "a");
487
488 let ids = vec!["a".to_string(), "b".to_string()];
489 let (qualifier, column) = form_identifier(&ids)?;
490 assert_eq!(qualifier, Some(TableReference::bare("a")));
491 assert_eq!(column, "b");
492
493 let ids = vec!["a".to_string(), "b".to_string(), "c".to_string()];
494 let (qualifier, column) = form_identifier(&ids)?;
495 assert_eq!(qualifier, Some(TableReference::partial("a", "b")));
496 assert_eq!(column, "c");
497
498 let ids = vec![
499 "a".to_string(),
500 "b".to_string(),
501 "c".to_string(),
502 "d".to_string(),
503 ];
504 let (qualifier, column) = form_identifier(&ids)?;
505 assert_eq!(qualifier, Some(TableReference::full("a", "b", "c")));
506 assert_eq!(column, "d");
507
508 let err = form_identifier(&[
509 "a".to_string(),
510 "b".to_string(),
511 "c".to_string(),
512 "d".to_string(),
513 "e".to_string(),
514 ])
515 .expect_err("too many identifiers didn't fail");
516 let expected = "Internal error: Incorrect number of identifiers: 5.\n\
517 This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this \
518 by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues";
519 assert!(expected.starts_with(&err.strip_backtrace()));
520
521 Ok(())
522 }
523}

Callers

nothing calls this directly

Calls 2

form_identifierFunction · 0.85
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…