1515import io .cloudquery .schema .Resource ;
1616import io .cloudquery .schema .Table ;
1717import java .io .IOException ;
18+ import java .time .LocalDate ;
1819import java .util .List ;
1920import java .util .Map ;
21+ import org .apache .arrow .vector .types .DateUnit ;
2022import org .apache .arrow .vector .types .pojo .ArrowType ;
2123import org .apache .arrow .vector .types .pojo .Field ;
2224import org .apache .arrow .vector .types .pojo .Schema ;
@@ -41,7 +43,11 @@ public class ArrowHelperTest {
4143 .primaryKey (true )
4244 .build (),
4345 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 ()))
4551 .build ();
4652
4753 @ Test
@@ -69,6 +75,9 @@ public void testToArrowSchema() {
6975 CQ_EXTENSION_PRIMARY_KEY ,
7076 "false" ));
7177
78+ assertEquals (arrowSchema .getFields ().get (2 ).getName (), "boolean_column" );
79+ assertEquals (arrowSchema .getFields ().get (3 ).getName (), "date_days_column" );
80+
7281 assertEquals (
7382 arrowSchema .getCustomMetadata (),
7483 Map .of (
@@ -84,7 +93,8 @@ public void testFromArrowSchema() {
8493 List <Field > fields =
8594 List .of (
8695 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 )));
8898
8999 Schema schema = new Schema (fields , Map .of (CQ_TABLE_NAME , "table1" ));
90100
@@ -120,6 +130,7 @@ public void testRoundTripResourceEncoding() throws Exception {
120130 Resource resource = Resource .builder ().table (TEST_TABLE ).build ();
121131 resource .set ("string_column1" , "test_data" );
122132 resource .set ("string_column2" , "test_data2" );
133+ resource .set ("date_days_column" , (int ) LocalDate .parse ("2023-11-24" ).toEpochDay ());
123134 resource .set ("boolean_column" , true );
124135
125136 Assertions .assertDoesNotThrow (
0 commit comments