1- use crate :: common:: nodes:: { ArcPredicateNode , PredicateNode , PredicateType , ReprPredicateNode } ;
1+ use crate :: common:: {
2+ nodes:: { ArcPredicateNode , PredicateNode , PredicateType , ReprPredicateNode } ,
3+ types:: TableId ,
4+ } ;
25
36use super :: id_pred:: IdPred ;
47
@@ -8,11 +11,14 @@ use super::id_pred::IdPred;
811/// 1. The table id, represented by an [`IdPred`].
912/// 2. The index of the column, represented by an [`IdPred`].
1013///
14+ /// **TODO**: Now we assume any IdPred is as same as the ones in the ORM layer.
15+ ///
1116/// Currently, [`AttributeRefPred`] only holds base table attributes, i.e. attributes
1217/// that already exist in the table. More complex structures may be introduced in the
1318/// future to represent derived attributes (e.g. t.v1 + t.v2).
1419///
1520/// TODO: Support derived column in `AttributeRefPred`.
21+ /// Proposal: Data field can store the column type (base or derived).
1622#[ derive( Clone , Debug ) ]
1723pub struct AttributeRefPred ( pub ArcPredicateNode ) ;
1824
@@ -32,11 +38,12 @@ impl AttributeRefPred {
3238 }
3339
3440 /// Gets the table id.
35- pub fn table_id ( & self ) -> usize {
36- self . 0 . child ( 0 ) . data . as_ref ( ) . unwrap ( ) . as_u64 ( ) as usize
41+ pub fn table_id ( & self ) -> TableId {
42+ TableId ( self . 0 . child ( 0 ) . data . as_ref ( ) . unwrap ( ) . as_u64 ( ) as usize )
3743 }
3844
3945 /// Gets the attribute index.
46+ /// Note: The attribute index is the **base** index, which is table specific.
4047 pub fn attr_index ( & self ) -> usize {
4148 self . 0 . child ( 1 ) . data . as_ref ( ) . unwrap ( ) . as_u64 ( ) as usize
4249 }
0 commit comments