()
| 801 | |
| 802 | #[test] |
| 803 | fn test_insert_infer_with_metadata() { |
| 804 | let uuid_field = Field::new("", DataType::FixedSizeBinary(16), false).with_metadata( |
| 805 | [("ARROW:extension:name".to_string(), "arrow.uuid".to_string())].into(), |
| 806 | ); |
| 807 | let uuid_bytes = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; |
| 808 | let expected_types = vec![ |
| 809 | ("$1", Some(uuid_field.clone().with_name("id").into())), |
| 810 | ( |
| 811 | "$2", |
| 812 | Some(Field::new("first_name", DataType::Utf8, false).into()), |
| 813 | ), |
| 814 | ( |
| 815 | "$3", |
| 816 | Some(Field::new("last_name", DataType::Utf8, false).into()), |
| 817 | ), |
| 818 | ]; |
| 819 | let param_values = vec![ |
| 820 | ScalarAndMetadata::new( |
| 821 | ScalarValue::FixedSizeBinary(16, Some(uuid_bytes)), |
| 822 | Some(uuid_field.metadata().into()), |
| 823 | ), |
| 824 | ScalarAndMetadata::from(ScalarValue::from("Alan")), |
| 825 | ScalarAndMetadata::from(ScalarValue::from("Turing")), |
| 826 | ]; |
| 827 | |
| 828 | // Check a normal insert |
| 829 | let test = ParameterTestWithMetadata { |
| 830 | sql: "insert into person_with_uuid_extension (id, first_name, last_name) values ($1, $2, $3)", |
| 831 | expected_types: expected_types.clone(), |
| 832 | param_values: param_values.clone(), |
| 833 | }; |
| 834 | |
| 835 | assert_snapshot!( |
| 836 | test.run(), |
| 837 | @r#" |
| 838 | ** Initial Plan: |
| 839 | Dml: op=[Insert Into] table=[person_with_uuid_extension] |
| 840 | Projection: column1 AS id, column2 AS first_name, column3 AS last_name |
| 841 | Values: ($1, $2, $3) |
| 842 | ** Final Plan: |
| 843 | Dml: op=[Insert Into] table=[person_with_uuid_extension] |
| 844 | Projection: column1 AS id, column2 AS first_name, column3 AS last_name |
| 845 | Values: (FixedSizeBinary(16, "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16") FieldMetadata { inner: {"ARROW:extension:name": "arrow.uuid"} } AS $1, Utf8("Alan") AS $2, Utf8("Turing") AS $3) |
| 846 | "# |
| 847 | ); |
| 848 | |
| 849 | // Check a prepared insert |
| 850 | let test = ParameterTestWithMetadata { |
| 851 | sql: "PREPARE my_plan AS insert into person_with_uuid_extension (id, first_name, last_name) values ($1, $2, $3)", |
| 852 | expected_types, |
| 853 | param_values, |
| 854 | }; |
| 855 | |
| 856 | assert_snapshot!( |
| 857 | test.run(), |
| 858 | @r#" |
| 859 | ** Initial Plan: |
| 860 | Prepare: "my_plan" [FixedSizeBinary(16)<{"ARROW:extension:name": "arrow.uuid"}>, Utf8, Utf8] |
nothing calls this directly
no test coverage detected
searching dependent graphs…