MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / testcase

Function testcase

src/sql-server-util/src/desc.rs:1447–1492  ·  view source on GitHub ↗
(
            data_type: &'static str,
            col_type: tiberius::ColumnType,
            col_data: tiberius::ColumnData<'static>,
        )

Source from the content-addressed store, hash-verified

1445 fn smoketest_decode_to_string() {
1446 #[track_caller]
1447 fn testcase(
1448 data_type: &'static str,
1449 col_type: tiberius::ColumnType,
1450 col_data: tiberius::ColumnData<'static>,
1451 ) {
1452 let columns = [SqlServerColumnRaw::new("a", data_type)];
1453 let sql_server_desc = SqlServerTableRaw {
1454 schema_name: "my_schema".into(),
1455 name: "my_table".into(),
1456 capture_instance: Arc::new(SqlServerCaptureInstanceRaw {
1457 name: "my_table_CT".into(),
1458 create_date: NaiveDateTime::parse_from_str(
1459 "2024-01-01 00:00:00",
1460 "%Y-%m-%d %H:%M:%S",
1461 )
1462 .unwrap()
1463 .into(),
1464 }),
1465 columns: columns.into(),
1466 };
1467 let mut sql_server_desc = SqlServerTableDesc::new(sql_server_desc, vec![]).unwrap();
1468 sql_server_desc.apply_text_columns(&BTreeSet::from(["a"]));
1469
1470 // We should support decoding every datatype to a string.
1471 let relation_desc = RelationDesc::builder()
1472 .with_column("a", SqlScalarType::String.nullable(false))
1473 .finish();
1474
1475 // This decoder should shape the SQL Server Rows into Rows compatible with the RelationDesc.
1476 let decoder = sql_server_desc
1477 .decoder(&relation_desc)
1478 .expect("known valid");
1479
1480 let sql_server_row = tiberius::Row::build([(
1481 tiberius::Column::new("a".to_string(), col_type),
1482 col_data,
1483 )]);
1484 let mut mz_row = Row::default();
1485 let arena = RowArena::new();
1486 decoder
1487 .decode(&sql_server_row, &mut mz_row, &arena, None)
1488 .unwrap();
1489
1490 let str_datum = mz_row.into_element();
1491 assert!(matches!(str_datum, Datum::String(_)));
1492 }
1493
1494 use tiberius::ColumnData;
1495

Callers 1

Calls 11

unwrapMethod · 0.80
apply_text_columnsMethod · 0.80
with_columnMethod · 0.80
expectMethod · 0.80
into_elementMethod · 0.80
buildFunction · 0.50
finishMethod · 0.45
nullableMethod · 0.45
decoderMethod · 0.45
to_stringMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected