15
15
import io .cloudquery .schema .Resource ;
16
16
import io .cloudquery .schema .Table ;
17
17
import java .io .IOException ;
18
+ import java .time .LocalDate ;
18
19
import java .util .List ;
19
20
import java .util .Map ;
21
+ import org .apache .arrow .vector .types .DateUnit ;
20
22
import org .apache .arrow .vector .types .pojo .ArrowType ;
21
23
import org .apache .arrow .vector .types .pojo .Field ;
22
24
import org .apache .arrow .vector .types .pojo .Schema ;
@@ -41,7 +43,11 @@ public class ArrowHelperTest {
41
43
.primaryKey (true )
42
44
.build (),
43
45
Column .builder ().name ("string_column2" ).type (ArrowType .Utf8 .INSTANCE ).build (),
44
- Column .builder ().name ("boolean_column" ).type (ArrowType .Bool .INSTANCE ).build ()))
46
+ Column .builder ().name ("boolean_column" ).type (ArrowType .Bool .INSTANCE ).build (),
47
+ Column .builder ()
48
+ .name ("date_days_column" )
49
+ .type (new ArrowType .Date (DateUnit .DAY ))
50
+ .build ()))
45
51
.build ();
46
52
47
53
@ Test
@@ -69,6 +75,9 @@ public void testToArrowSchema() {
69
75
CQ_EXTENSION_PRIMARY_KEY ,
70
76
"false" ));
71
77
78
+ assertEquals (arrowSchema .getFields ().get (2 ).getName (), "boolean_column" );
79
+ assertEquals (arrowSchema .getFields ().get (3 ).getName (), "date_days_column" );
80
+
72
81
assertEquals (
73
82
arrowSchema .getCustomMetadata (),
74
83
Map .of (
@@ -84,7 +93,8 @@ public void testFromArrowSchema() {
84
93
List <Field > fields =
85
94
List .of (
86
95
Field .nullable ("string_column1" , ArrowType .Utf8 .INSTANCE ),
87
- Field .nullable ("string_column2" , ArrowType .Utf8 .INSTANCE ));
96
+ Field .nullable ("string_column2" , ArrowType .Utf8 .INSTANCE ),
97
+ Field .nullable ("date_days_column" , new ArrowType .Date (DateUnit .DAY )));
88
98
89
99
Schema schema = new Schema (fields , Map .of (CQ_TABLE_NAME , "table1" ));
90
100
@@ -120,6 +130,7 @@ public void testRoundTripResourceEncoding() throws Exception {
120
130
Resource resource = Resource .builder ().table (TEST_TABLE ).build ();
121
131
resource .set ("string_column1" , "test_data" );
122
132
resource .set ("string_column2" , "test_data2" );
133
+ resource .set ("date_days_column" , (int ) LocalDate .parse ("2023-11-24" ).toEpochDay ());
123
134
resource .set ("boolean_column" , true );
124
135
125
136
Assertions .assertDoesNotThrow (
0 commit comments