@@ -35,7 +35,7 @@ public function testCast()
3535 }
3636 }
3737
38- public function testConvert ()
38+ public function testConvertSkipHeader ()
3939 {
4040 $ resultSet = [
4141 'Rows ' => [
@@ -107,10 +107,96 @@ public function testConvert()
107107 'column_name2 ' => 3
108108 ]
109109 ];
110+ $ this ->assertSame (
111+ $ expected ,
112+ ConvertAthenaQueryResultstoArray::convert ($ resultSet , true )
113+ );
114+ }
115+
116+ public function testConvertNotSkipHeader ()
117+ {
118+ $ resultSet = [
119+ 'Rows ' => [
120+ [
121+ 'Data ' => [
122+ ['VarCharValue ' => 'column_name1 ' ],
123+ ['VarCharValue ' => 'column_name2 ' ]
124+ ]
125+ ],
126+ [
127+ 'Data ' => [
128+ ['VarCharValue ' => 'value1 ' ],
129+ ['VarCharValue ' => '1 ' ]
130+ ]
131+ ],
132+ [
133+ 'Data ' => [
134+ ['VarCharValue ' => 'value2 ' ],
135+ ['VarCharValue ' => '2 ' ]
136+ ]
137+ ],
138+ [
139+ 'Data ' => [
140+ ['VarCharValue ' => 'value3 ' ],
141+ ['VarCharValue ' => '3 ' ]
142+ ]
143+ ]
144+ ],
145+ 'ResultSetMetadata ' => [
146+ 'ColumnInfo ' => [
147+ [
148+ 'CatalogName ' => 'hive ' ,
149+ 'SchemaName ' => '' ,
150+ 'TableName ' => '' ,
151+ 'Name ' => 'column_name1 ' ,
152+ 'Label ' => 'column_name1 ' ,
153+ 'Type ' => 'varchar ' ,
154+ 'Precision ' => 2147483647 ,
155+ 'Scale ' => 0 ,
156+ 'Nullable ' => 'UNKNOWN ' ,
157+ 'CaseSensitive ' => true
158+ ],
159+ [
160+ 'CatalogName ' => 'hive ' ,
161+ 'SchemaName ' => '' ,
162+ 'TableName ' => '' ,
163+ 'Name ' => 'column_name2 ' ,
164+ 'Label ' => 'column_name2 ' ,
165+ 'Type ' => 'integer ' ,
166+ 'Precision ' => 10 ,
167+ 'Scale ' => 0 ,
168+ 'Nullable ' => 'UNKNOWN ' ,
169+ 'CaseSensitive ' => false
170+ ]
171+ ]
172+ ]
173+ ];
174+ $ expected = [
175+ [
176+ 'column_name1 ' => 'column_name1 ' ,
177+ 'column_name2 ' => 0
178+ ],
179+ [
180+ 'column_name1 ' => 'value1 ' ,
181+ 'column_name2 ' => 1
182+ ],
183+ [
184+ 'column_name1 ' => 'value2 ' ,
185+ 'column_name2 ' => 2
186+ ],
187+ [
188+ 'column_name1 ' => 'value3 ' ,
189+ 'column_name2 ' => 3
190+ ]
191+ ];
110192 $ this ->assertSame (
111193 $ expected ,
112194 ConvertAthenaQueryResultstoArray::convert ($ resultSet )
113195 );
196+ $ this ->assertSame (
197+ $ expected ,
198+ ConvertAthenaQueryResultstoArray::convert ($ resultSet , false )
199+ );
114200 }
115201
116202 public function testConvertWithoutVarCharValue ()
@@ -187,7 +273,7 @@ public function testConvertWithoutVarCharValue()
187273 ];
188274 $ this ->assertSame (
189275 $ expected ,
190- ConvertAthenaQueryResultstoArray::convert ($ resultSet )
276+ ConvertAthenaQueryResultstoArray::convert ($ resultSet, true )
191277 );
192278 }
193279}
0 commit comments