Skip to content

Commit e25db98

Browse files
committed
test: ephemeral columns are broken after #244
1 parent 8cf3d2e commit e25db98

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

tests/it/rbwnat_smoke.rs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,3 +1412,84 @@ async fn interval() {
14121412
}
14131413
);
14141414
}
1415+
1416+
// See https://clickhouse.com/docs/sql-reference/statements/create/table#ephemeral
1417+
//
1418+
// Ignored cause:
1419+
//
1420+
// #### All struct fields:
1421+
// - id
1422+
// - unhexed
1423+
// #### All schema columns:
1424+
// - id: UInt64
1425+
// - hexed: FixedString(4)
1426+
#[tokio::test]
1427+
#[ignore]
1428+
async fn ephemeral_columns() {
1429+
#[derive(Clone, Debug, Row, Serialize, PartialEq)]
1430+
struct DataInsert {
1431+
id: u64,
1432+
unhexed: String,
1433+
}
1434+
1435+
#[derive(Clone, Debug, Row, Deserialize, PartialEq)]
1436+
struct DataSelect {
1437+
id: u64,
1438+
hexed: [u8; 4],
1439+
}
1440+
1441+
let client = get_client();
1442+
client
1443+
.query(
1444+
"
1445+
CREATE OR REPLACE TABLE test
1446+
(
1447+
id UInt64,
1448+
unhexed String EPHEMERAL,
1449+
hexed FixedString(4) DEFAULT unhex(unhexed)
1450+
)
1451+
ENGINE = MergeTree
1452+
ORDER BY id
1453+
",
1454+
)
1455+
.execute()
1456+
.await
1457+
.unwrap();
1458+
1459+
let rows_to_insert = vec![
1460+
DataInsert {
1461+
id: 1,
1462+
unhexed: "41424344".to_string(), // "ABCD" in hex
1463+
},
1464+
DataInsert {
1465+
id: 2,
1466+
unhexed: "31323334".to_string(), // "1234" in hex
1467+
},
1468+
];
1469+
1470+
let mut insert = client.insert::<DataInsert>("test").await.unwrap();
1471+
for row in rows_to_insert.into_iter() {
1472+
insert.write(&row).await.unwrap();
1473+
}
1474+
insert.end().await.unwrap();
1475+
1476+
let rows = client
1477+
.query("SELECT ?fields FROM test ORDER BY () ASC")
1478+
.fetch_all::<DataSelect>()
1479+
.await
1480+
.unwrap();
1481+
1482+
assert_eq!(
1483+
rows,
1484+
vec![
1485+
DataSelect {
1486+
id: 1,
1487+
hexed: *b"ABCD",
1488+
},
1489+
DataSelect {
1490+
id: 2,
1491+
hexed: *b"1234",
1492+
},
1493+
]
1494+
);
1495+
}

0 commit comments

Comments
 (0)