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

Function test_ffi_session

datafusion/ffi/src/session/mod.rs:659–721  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

657
658 #[tokio::test]
659 async fn test_ffi_session() -> Result<(), DataFusionError> {
660 let (ctx, task_ctx_provider) = crate::util::tests::test_session_and_ctx();
661 let mut table_options = TableOptions::default();
662 table_options.csv.has_header = Some(true);
663 table_options.json.schema_infer_max_rec = Some(10);
664 table_options.parquet.global.coerce_int96 = Some("123456789".into());
665 table_options.current_format = Some(ConfigFileType::JSON);
666
667 let state = SessionStateBuilder::new_from_existing(ctx.state())
668 .with_table_options(table_options)
669 .build();
670
671 let logical_codec = FFI_LogicalExtensionCodec::new(
672 Arc::new(DefaultLogicalExtensionCodec {}),
673 None,
674 task_ctx_provider,
675 );
676
677 let local_session = FFI_SessionRef::new(&state, None, logical_codec);
678 let foreign_session = ForeignSession::try_from(&local_session)?;
679
680 let schema = Arc::new(Schema::new(vec![Field::new("a", DataType::Int32, false)]));
681 let df_schema = schema.try_into()?;
682 let physical_expr = foreign_session.create_physical_expr(col("a"), &df_schema)?;
683 assert_eq!(
684 format!("{physical_expr:?}"),
685 "Column { name: \"a\", index: 0 }"
686 );
687
688 assert_eq!(foreign_session.session_id(), state.session_id());
689
690 let logical_plan = LogicalPlan::default();
691 let physical_plan = foreign_session.create_physical_plan(&logical_plan).await?;
692 assert_eq!(
693 format!("{physical_plan:?}"),
694 "EmptyExec { schema: Schema { fields: [], metadata: {} }, partitions: 1, cache: PlanProperties { eq_properties: EquivalenceProperties { eq_group: EquivalenceGroup { map: {}, classes: [] }, oeq_class: OrderingEquivalenceClass { orderings: [] }, oeq_cache: OrderingEquivalenceCache { normal_cls: OrderingEquivalenceClass { orderings: [] }, leading_map: {} }, constraints: Constraints { inner: [] }, schema: Schema { fields: [], metadata: {} } }, partitioning: UnknownPartitioning(1), emission_type: Incremental, boundedness: Bounded, evaluation_type: Lazy, scheduling_type: Cooperative, output_ordering: None } }"
695 );
696
697 assert_eq!(
698 format!("{:?}", foreign_session.default_table_options()),
699 format!("{:?}", state.default_table_options())
700 );
701
702 assert_eq!(
703 format!("{:?}", foreign_session.table_options()),
704 format!("{:?}", state.table_options())
705 );
706
707 let local_udfs = state.udfs();
708 for udf in foreign_session.scalar_functions().keys() {
709 assert!(local_udfs.contains(udf));
710 }
711 let local_udafs = state.udafs();
712 for udaf in foreign_session.aggregate_functions().keys() {
713 assert!(local_udafs.contains(udaf));
714 }
715 let local_udwfs = state.udwfs();
716 for udwf in foreign_session.window_functions().keys() {

Callers

nothing calls this directly

Calls 15

test_session_and_ctxFunction · 0.85
newFunction · 0.85
with_table_optionsMethod · 0.80
colFunction · 0.50
intoMethod · 0.45
buildMethod · 0.45
stateMethod · 0.45
create_physical_exprMethod · 0.45
create_physical_planMethod · 0.45
udfsMethod · 0.45
scalar_functionsMethod · 0.45
udafsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…