@@ -6,17 +6,14 @@ use polars_core::datatypes::{
66 BooleanChunked , Int16Chunked , Int8Chunked , UInt16Chunked , UInt8Chunked ,
77} ;
88use polars_core:: frame:: DataFrame ;
9- use polars_core:: prelude:: {
10- Column , Float32Chunked , Float64Chunked , Int32Chunked , Int64Chunked , IntoColumn , UInt32Chunked ,
11- UInt64Chunked ,
12- } ;
9+ use polars_core:: prelude:: { Column , DecimalChunked , Float32Chunked , Float64Chunked , Int128Chunked , Int32Chunked , Int64Chunked , IntoColumn , NewChunkedArray , UInt32Chunked , UInt64Chunked } ;
1310use polars_core:: series:: Series ;
1411use representation:: {
1512 BaseRDFNodeType , LANG_STRING_LANG_FIELD , LANG_STRING_VALUE_FIELD , OBJECT_COL_NAME ,
1613 SUBJECT_COL_NAME ,
1714} ;
1815use std:: collections:: HashSet ;
19- use representation:: rdf_to_polars:: { default_time_unit, default_time_zone} ;
16+ use representation:: rdf_to_polars:: { default_decimal_precision , default_decimal_scale , default_time_unit, default_time_zone} ;
2017
2118pub fn bool_chunked ( c : & Column ) -> & BooleanChunked {
2219 c. bool ( ) . unwrap ( )
@@ -66,6 +63,10 @@ pub fn datetime_chunked(c: &Column) -> &Int64Chunked {
6663 c. datetime ( ) . unwrap ( ) . physical ( )
6764}
6865
66+ pub fn decimal_chunked ( c : & Column ) -> & Int128Chunked {
67+ c. decimal ( ) . unwrap ( ) . physical ( )
68+ }
69+
6970
7071pub fn bool_vec_to_column ( col_name : & str , vec : Vec < bool > ) -> Column {
7172 let mut c = Series :: from_iter ( vec) . into_column ( ) ;
@@ -117,6 +118,11 @@ pub fn datetime_vec_to_column(col_name: &str, vec: Vec<i64>) -> Column {
117118 o_series. into_column ( )
118119}
119120
121+ pub fn decimal_vec_to_column ( col_name : & str , vec : Vec < i128 > ) -> Column {
122+ let o_series = Int128Chunked :: from_vec ( PlSmallStr :: from_str ( col_name) , vec) . into_decimal ( default_decimal_precision ( ) , default_decimal_scale ( ) ) . unwrap ( ) ;
123+ o_series. into_column ( )
124+ }
125+
120126pub fn unwrap_ordered_float < T > ( o : Option < T > ) -> OrderedFloat < T > {
121127 OrderedFloat ( o. unwrap ( ) )
122128}
@@ -510,6 +516,18 @@ binary_nonlang_nonlang_index_impl!(
510516 datetime_vec_to_column
511517) ;
512518
519+ binary_nonlang_nonlang_index_impl ! (
520+ U32DecimalIndex ,
521+ ( u32 , i128 ) ,
522+ u32_chunked,
523+ decimal_chunked,
524+ unwrap_t,
525+ noop_t,
526+ noop_t,
527+ u32_vec_to_column,
528+ decimal_vec_to_column
529+ ) ;
530+
513531binary_nonlang_lang_index_impl ! (
514532 U32LangIndex ,
515533 ( u32 , u32 , u32 ) ,
@@ -533,6 +551,7 @@ pub enum SubjectObjectIndex {
533551 U32I64Index ( U32I64Index ) ,
534552 U32F32Index ( U32F32Index ) ,
535553 U32F64Index ( U32F64Index ) ,
554+ U32DecimalIndex ( U32DecimalIndex ) ,
536555 U32DateIndex ( U32DateIndex ) ,
537556 U32DateTimeIndex ( U32DateTimeIndex ) ,
538557}
@@ -553,9 +572,11 @@ impl SubjectObjectIndex {
553572 SubjectObjectIndex :: U32BoolIndex ( U32BoolIndex :: new ( ) )
554573 } else if object_type. is_lit_type ( xsd:: FLOAT ) {
555574 SubjectObjectIndex :: U32F32Index ( U32F32Index :: new ( ) )
556- } else if object_type. is_lit_type ( xsd:: DOUBLE ) || object_type . is_lit_type ( xsd :: DECIMAL )
575+ } else if object_type. is_lit_type ( xsd:: DOUBLE )
557576 {
558577 SubjectObjectIndex :: U32F64Index ( U32F64Index :: new ( ) )
578+ } else if object_type. is_lit_type ( xsd:: DECIMAL ) {
579+ SubjectObjectIndex :: U32DecimalIndex ( U32DecimalIndex :: new ( ) )
559580 } else if object_type. is_lit_type ( xsd:: BYTE ) {
560581 SubjectObjectIndex :: U32I8Index ( U32I8Index :: new ( ) )
561582 } else if object_type. is_lit_type ( xsd:: UNSIGNED_BYTE ) {
@@ -592,6 +613,7 @@ impl SubjectObjectIndex {
592613 SubjectObjectIndex :: U32I64Index ( i) => i. insert ( df) ,
593614 SubjectObjectIndex :: U32F32Index ( i) => i. insert ( df) ,
594615 SubjectObjectIndex :: U32F64Index ( i) => i. insert ( df) ,
616+ SubjectObjectIndex :: U32DecimalIndex ( i) => i. insert ( df) ,
595617 SubjectObjectIndex :: U32DateIndex ( i) => i. insert ( df) ,
596618 SubjectObjectIndex :: U32DateTimeIndex ( i) => i. insert ( df) ,
597619 SubjectObjectIndex :: U32BoolIndex ( i) => i. insert ( df) ,
@@ -611,6 +633,7 @@ impl SubjectObjectIndex {
611633 SubjectObjectIndex :: U32I64Index ( i) => i. delete ( df) ,
612634 SubjectObjectIndex :: U32F32Index ( i) => i. delete ( df) ,
613635 SubjectObjectIndex :: U32F64Index ( i) => i. delete ( df) ,
636+ SubjectObjectIndex :: U32DecimalIndex ( i) => i. delete ( df) ,
614637 SubjectObjectIndex :: U32DateIndex ( i) => i. delete ( df) ,
615638 SubjectObjectIndex :: U32DateTimeIndex ( i) => i. delete ( df) ,
616639 SubjectObjectIndex :: U32BoolIndex ( i) => i. delete ( df) ,
0 commit comments