1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::data::datatable::{DataColumn, DataRow, DataTable, DataValue};
fn create_test_table() -> DataTable {
let mut table = DataTable::new("test");
table.add_column(DataColumn::new("id"));
table.add_column(DataColumn::new("quantity"));
table.add_column(DataColumn::new("price"));
table
.add_row(DataRow::new(vec![
DataValue::Integer(1),
DataValue::Integer(10),
DataValue::Float(100.5),
]))
.unwrap();
table
.add_row(DataRow::new(vec![
DataValue::Integer(2),
DataValue::Integer(5),
DataValue::Float(200.25),
]))
.unwrap();
table
}
#[test]
#[ignore = "Need to test through execute method with proper SQL"]
fn test_duplicate_columns_get_aliased() {
// The duplicate column handling is implemented in query_engine.rs
// in the apply_select_items method.
// When duplicate columns are selected, they get auto-aliased:
// - First occurrence: "quantity"
// - Second occurrence: "quantity_1"
// - Third occurrence: "quantity_2"
// This allows queries like: SELECT quantity, quantity * price as total, quantity
}
#[test]
#[ignore = "Need to test through execute method with proper SQL"]
fn test_duplicate_with_computed_columns() {
// The duplicate column handling also works with computed columns.
// A query like: SELECT quantity * price as total, quantity, total
// Would create columns: total, quantity, total_1
// This ensures users can select the same column multiple times
// especially when using computed expressions.
}