package Ġcom . sk sam uel . cent ur ion . parquet Ċ Ċ import Ġcom . sk sam uel . cent ur ion . Schema Ċ import Ġcom . sk sam uel . cent ur ion . nullable Ċ import Ġcom . sk sam uel . cent ur ion . parquet . schemas . To Par quet Schema Ċ import Ġio . kot est . core . spec . style . Fun Spec Ċ import Ġio . kot est . matchers . shouldBe Ċ import Ġorg . apache . parquet . schema . Logical Type Annotation Ċ import Ġorg . apache . parquet . schema . Primitive Type Ċ import Ġorg . apache . parquet . schema . Type Ċ import Ġorg . apache . parquet . schema . Types Ċ Ċ class ĠTo Par quet Schema Test Ġ: ĠFun Spec () Ġ{ ĊĊĠ Ġinit Ġ{ ĊĊĠĠĠ Ġtest (" integr als ") Ġ{ ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . Int 8 , Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . INT 3 2 , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . int Type ( 8 , Ġtrue )). named (" a ") ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . Int 1 6 , Ġ" b ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . INT 3 2 , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . int Type ( 1 6 , Ġtrue )). named (" b ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" structs Ġshould Ġbe Ġconverted Ġto Ġpar quet Ġmessage Ġtype ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġstruct Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" my record ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . Strings ), ĊĠĠĠĠĠĠĠ ĠSchema . Field (" b ", ĠSchema . B ooleans . nullable ()), ĊĠĠĠĠĠĠĠ ĠSchema . Field (" c ", ĠSchema . Float 6 4 ), ĊĠĠĠĠĠĠĠ ĠSchema . Field (" d ", ĠSchema . Int 6 4 . nullable ()) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( struct ) ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . build Message () ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . string Type ()). named (" a ") ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( Types . primitive ( Primitive Type . Primitive TypeName . BOOLEAN , ĠType . Re petition . OPTIONAL ). named (" b ")) ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( Types . primitive ( Primitive Type . Primitive TypeName . DOUBLE , ĠType . Re petition . REQUIRED ). named (" c ")) ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( Types . primitive ( Primitive Type . Primitive TypeName . INT 6 4 , ĠType . Re petition . OPTIONAL ). named (" d ")) ĊĠĠĠĠĠĠĠĠĠ Ġ. named (" my record ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" Schema . Strings Ġshould Ġbe Ġconverted Ġto ĠBinary Ġwith ĠLogical Type Annotation . string ") Ġ{ ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . Strings , Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . string Type ()). named (" a ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" Schema . uuid s Ġshould Ġbe Ġconverted Ġto ĠBinary Ġwith ĠLogical Type Annotation . string ") Ġ{ ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . UUID , Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . string Type ()). named (" a ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" Schema . Timestamp Millis Ġshould Ġbe Ġconverted Ġto ĠINT 6 4 Ġwith ĠLogical Type Annotation . TimeUnit . M ILL IS ") Ġ{ ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . Timestamp Millis , Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . INT 6 4 , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . timestamp Type ( true , ĠLogical Type Annotation . TimeUnit . M ILL IS )). named (" a ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" Schema . Timestamp Micro s Ġshould Ġbe Ġconverted Ġto ĠINT 6 4 Ġwith ĠLogical Type Annotation . TimeUnit . MIC ROS ") Ġ{ ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . Timestamp Micro s , Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . INT 6 4 , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . timestamp Type ( true , ĠLogical Type Annotation . TimeUnit . MIC ROS )). named (" a ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" Schema . Bytes Ġshould Ġbe Ġconverted Ġto ĠBINARY ") Ġ{ ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . Bytes , Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ). named (" a ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" nested Ġstructs ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" my record ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . B ooleans ), ĊĠĠĠĠĠĠĠ ĠSchema . Field ( ĊĠĠĠĠĠĠĠĠĠ Ġ" b ", ĊĠĠĠĠĠĠĠĠĠ ĠSchema . Struct ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" my record 2 ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSchema . Field (" c ", ĠSchema . Float 6 4 ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSchema . Field (" d ", ĠSchema . Float 3 2 ) ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġval Ġb Ġ= ĠTypes . build Group ( Type . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠ Ġ. addField ( Types . primitive ( Primitive Type . Primitive TypeName . DOUBLE , ĠType . Re petition . REQUIRED ). named (" c ")) ĊĠĠĠĠĠĠĠ Ġ. addField ( Types . primitive ( Primitive Type . Primitive TypeName . FLOAT , ĠType . Re petition . REQUIRED ). named (" d ")) ĊĠĠĠĠĠĠĠ Ġ. named (" b ") ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( schema ) ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . build Message () ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( Types . primitive ( Primitive Type . Primitive TypeName . BOOLEAN , ĠType . Re petition . REQUIRED ). named (" a ")) ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( b ) ĊĠĠĠĠĠĠĠĠĠ Ġ. named (" my record ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" arrays Ġof Ġprimitives ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" my record ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . Strings ), ĊĠĠĠĠĠĠĠ ĠSchema . Field (" b ", ĠSchema . Array ( Schema . Int 3 2 )), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( schema ) ĠshouldBe ĠTypes . build Message () ĊĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . string Type ()). named (" a ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠ ĠTypes . list ( Type . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. element ( Types . primitive ( Primitive Type . Primitive TypeName . INT 3 2 , ĠType . Re petition . REQUIRED ). named (" element ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. named (" b ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ. named (" my record ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" optional Ġarrays Ġof Ġprimitives ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" my record ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . Strings ), ĊĠĠĠĠĠĠĠ ĠSchema . Field (" b ", ĠSchema . Array ( Schema . Int 3 2 ). nullable ()), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( schema ) ĠshouldBe ĠTypes . build Message () ĊĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . string Type ()). named (" a ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠ ĠTypes . list ( Type . Re petition . OPTIONAL ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. element ( Types . primitive ( Primitive Type . Primitive TypeName . INT 3 2 , ĠType . Re petition . REQUIRED ). named (" element ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. named (" b ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ. named (" my record ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" arrays Ġof Ġstructs ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" x ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . Bytes ), ĊĠĠĠĠĠĠĠ ĠSchema . Field (" b ", ĠSchema . Array ( Schema . Struct (" y ", ĠSchema . Field (" c ", ĠSchema . B ooleans )))) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( schema ) ĠshouldBe ĠTypes . build Message () ĊĠĠĠĠĠĠĠ Ġ. addField ( Types . required ( Primitive Type . Primitive TypeName . BINARY ). named (" a ")) ĊĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠ ĠTypes . list ( Type . Re petition . REQUIRED ). element ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTypes ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. build Group ( Type . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. addField ( Types . required ( Primitive Type . Primitive TypeName . BOOLEAN ). named (" c ")) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. named (" element ") ĊĠĠĠĠĠĠĠĠĠ Ġ). named (" b ") ĊĠĠĠĠĠĠĠ Ġ). named (" x ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" required Ġfields ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" my record ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . Bytes ), ĊĠĠĠĠĠĠĠ ĠSchema . Field (" b ", ĠSchema . B ooleans ), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( schema ) ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . build Message () ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( Types . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ). named (" a ")) ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( Types . primitive ( Primitive Type . Primitive TypeName . BOOLEAN , ĠType . Re petition . REQUIRED ). named (" b ")) ĊĠĠĠĠĠĠĠĠĠ Ġ. named (" my record ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" Schema . Enum Ġshould Ġbe Ġconverted Ġto Ġannotated ĠBinary ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġstruct Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" my record ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . Enum (" mal bec ", Ġ" pin ot Ġno ir ")), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( struct ) ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . build Message () ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . enum Type ()). named (" a ") ĊĠĠĠĠĠĠĠĠĠ Ġ). named (" my record ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" maps ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġstruct Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" my record ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . Map ( Schema . Int 6 4 , ĠSchema . B ooleans )), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( struct ) ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . build Message () ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTypes ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map ( Type . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. key ( Types . required ( Primitive Type . Primitive TypeName . INT 6 4 ). named (" key ")) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. value ( Types . required ( Primitive Type . Primitive TypeName . BOOLEAN ). named (" value ")). named (" a ") ĊĠĠĠĠĠĠĠĠĠ Ġ). named (" my record ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" optional Ġmaps Ġof Ġb ooleans ") Ġ{ ĊĊĠĠĠĠĠ Ġval Ġstruct Ġ= ĠSchema . Struct ( ĊĠĠĠĠĠĠĠ Ġ" my record ", ĊĠĠĠĠĠĠĠ ĠSchema . Field (" a ", ĠSchema . Map ( Schema . Strings , ĠSchema . B ooleans ). nullable ()), ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to MessageType ( struct ) ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . build Message () ĊĠĠĠĠĠĠĠĠĠ Ġ. addField ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTypes . map ( Type . Re petition . OPTIONAL ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. key ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BINARY , ĠType . Re petition . REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . string Type ()). named (" key ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ). value ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠTypes . primitive ( Primitive Type . Primitive TypeName . BOOLEAN , ĠType . Re petition . REQUIRED ). named (" value ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ). named (" a ") ĊĠĠĠĠĠĠĠĠĠ Ġ). named (" my record ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" decimals ") Ġ{ ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . Decimal ( Schema . Precision ( 5 ), ĠSchema . Scale ( 2 )), Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . required ( Primitive Type . Primitive TypeName . INT 3 2 ). ` as `( Logical Type Annotation . decimal Type ( 2 , Ġ 5 )). named (" a ") ĊĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . Decimal ( Schema . Precision ( 1 4 ), ĠSchema . Scale ( 2 )), Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . required ( Primitive Type . Primitive TypeName . INT 6 4 ). ` as `( Logical Type Annotation . decimal Type ( 2 , Ġ 1 4 )). named (" a ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" enums ") Ġ{ ĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠSchema . Enum (" mal bec ", Ġ" pin ot ", Ġ" sh ir az ") ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( schema , Ġ" enum ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . required ( Primitive Type . Primitive TypeName . BINARY ) ĊĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . enum Type ()) ĊĠĠĠĠĠĠĠĠĠ Ġ. named (" enum ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtest (" varchar s ") Ġ{ ĊĠĠĠĠĠ ĠTo Par quet Schema . to Par quet Type ( Schema . V arch ar ( 1 2 3 ), Ġ" a ") ĠshouldBe ĊĠĠĠĠĠĠĠ ĠTypes . required ( Primitive Type . Primitive TypeName . BINARY ) ĊĠĠĠĠĠĠĠĠĠ Ġ. ` as `( Logical Type Annotation . string Type ()) ĊĠĠĠĠĠĠĠĠĠ Ġ. named (" a ") ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ