@@ -55,14 +55,14 @@ struct Identifier<'n> {
55
55
}
56
56
57
57
impl < ' n > Identifier < ' n > {
58
- pub fn new ( expr : & ' n Expr , random_state : & RandomState ) -> Self {
58
+ fn new ( expr : & ' n Expr , random_state : & RandomState ) -> Self {
59
59
let mut hasher = random_state. build_hasher ( ) ;
60
60
expr. hash_node ( & mut hasher) ;
61
61
let hash = hasher. finish ( ) ;
62
62
Self { hash, expr }
63
63
}
64
64
65
- pub fn combine ( mut self , other : Option < Self > ) -> Self {
65
+ fn combine ( mut self , other : Option < Self > ) -> Self {
66
66
other. map_or ( self , |other_id| {
67
67
self . hash = combine_hashes ( self . hash , other_id. hash ) ;
68
68
self
@@ -76,12 +76,6 @@ impl Hash for Identifier<'_> {
76
76
}
77
77
}
78
78
79
- impl From < Identifier < ' _ > > for String {
80
- fn from ( id : Identifier < ' _ > ) -> Self {
81
- format ! ( "common_{}" , id. hash)
82
- }
83
- }
84
-
85
79
/// A cache that contains the postorder index and the identifier of expression tree nodes
86
80
/// by the preorder index of the nodes.
87
81
///
@@ -1554,42 +1548,37 @@ mod test {
1554
1548
Ok ( ( ) )
1555
1549
}
1556
1550
1551
+ fn test_identifier ( hash : u64 , expr : & Expr ) -> Identifier {
1552
+ Identifier {
1553
+ hash,
1554
+ expr,
1555
+ }
1556
+ }
1557
+
1557
1558
#[ test]
1558
1559
fn redundant_project_fields ( ) {
1559
1560
let table_scan = test_table_scan ( ) . unwrap ( ) ;
1560
1561
let c_plus_a = col ( "c" ) + col ( "a" ) ;
1561
1562
let b_plus_a = col ( "b" ) + col ( "a" ) ;
1562
1563
let common_exprs_1 = CommonExprs :: from ( [
1563
1564
(
1564
- Identifier {
1565
- hash : 0 ,
1566
- expr : & c_plus_a,
1567
- } ,
1565
+ test_identifier ( 0 , & c_plus_a) ,
1568
1566
( c_plus_a. clone ( ) , format ! ( "{CSE_PREFIX}_1" ) ) ,
1569
1567
) ,
1570
1568
(
1571
- Identifier {
1572
- hash : 1 ,
1573
- expr : & b_plus_a,
1574
- } ,
1569
+ test_identifier ( 1 , & b_plus_a) ,
1575
1570
( b_plus_a. clone ( ) , format ! ( "{CSE_PREFIX}_2" ) ) ,
1576
1571
) ,
1577
1572
] ) ;
1578
1573
let c_plus_a_2 = col ( format ! ( "{CSE_PREFIX}_1" ) ) ;
1579
1574
let b_plus_a_2 = col ( format ! ( "{CSE_PREFIX}_2" ) ) ;
1580
1575
let common_exprs_2 = CommonExprs :: from ( [
1581
1576
(
1582
- Identifier {
1583
- hash : 3 ,
1584
- expr : & c_plus_a_2,
1585
- } ,
1577
+ test_identifier ( 3 , & c_plus_a_2) ,
1586
1578
( c_plus_a_2. clone ( ) , format ! ( "{CSE_PREFIX}_3" ) ) ,
1587
1579
) ,
1588
1580
(
1589
- Identifier {
1590
- hash : 4 ,
1591
- expr : & b_plus_a_2,
1592
- } ,
1581
+ test_identifier ( 4 , & b_plus_a_2) ,
1593
1582
( b_plus_a_2. clone ( ) , format ! ( "{CSE_PREFIX}_4" ) ) ,
1594
1583
) ,
1595
1584
] ) ;
@@ -1615,35 +1604,23 @@ mod test {
1615
1604
let b_plus_a = col ( "test1.b" ) + col ( "test1.a" ) ;
1616
1605
let common_exprs_1 = CommonExprs :: from ( [
1617
1606
(
1618
- Identifier {
1619
- hash : 0 ,
1620
- expr : & c_plus_a,
1621
- } ,
1607
+ test_identifier ( 0 , & c_plus_a) ,
1622
1608
( c_plus_a. clone ( ) , format ! ( "{CSE_PREFIX}_1" ) ) ,
1623
1609
) ,
1624
1610
(
1625
- Identifier {
1626
- hash : 1 ,
1627
- expr : & b_plus_a,
1628
- } ,
1611
+ test_identifier ( 1 , & b_plus_a) ,
1629
1612
( b_plus_a. clone ( ) , format ! ( "{CSE_PREFIX}_2" ) ) ,
1630
1613
) ,
1631
1614
] ) ;
1632
1615
let c_plus_a_2 = col ( format ! ( "{CSE_PREFIX}_1" ) ) ;
1633
1616
let b_plus_a_2 = col ( format ! ( "{CSE_PREFIX}_2" ) ) ;
1634
1617
let common_exprs_2 = CommonExprs :: from ( [
1635
1618
(
1636
- Identifier {
1637
- hash : 3 ,
1638
- expr : & c_plus_a_2,
1639
- } ,
1619
+ test_identifier ( 3 , & c_plus_a_2) ,
1640
1620
( c_plus_a_2. clone ( ) , format ! ( "{CSE_PREFIX}_3" ) ) ,
1641
1621
) ,
1642
1622
(
1643
- Identifier {
1644
- hash : 4 ,
1645
- expr : & b_plus_a_2,
1646
- } ,
1623
+ test_identifier ( 4 , & b_plus_a_2) ,
1647
1624
( b_plus_a_2. clone ( ) , format ! ( "{CSE_PREFIX}_4" ) ) ,
1648
1625
) ,
1649
1626
] ) ;
0 commit comments