@@ -269,7 +269,71 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
269269 |)
270270 """ .stripMargin.cmd,
271271 s " LOAD DATA LOCAL INPATH ' ${getHiveFile(" data/files/episodes.avro" )}' INTO TABLE episodes " .cmd
272- )
272+ ),
273+ // THIS TABLE IS NOT THE SAME AS THE HIVE TEST TABLE episodes_partitioned AS DYNAMIC PARITIONING
274+ // IS NOT YET SUPPORTED
275+ TestTable (" episodes_part" ,
276+ s """ CREATE TABLE episodes_part (title STRING, air_date STRING, doctor INT)
277+ |PARTITIONED BY (doctor_pt INT)
278+ |ROW FORMAT SERDE ' ${classOf [AvroSerDe ].getCanonicalName}'
279+ |STORED AS
280+ |INPUTFORMAT ' ${classOf [AvroContainerInputFormat ].getCanonicalName}'
281+ |OUTPUTFORMAT ' ${classOf [AvroContainerOutputFormat ].getCanonicalName}'
282+ |TBLPROPERTIES (
283+ | 'avro.schema.literal'='{
284+ | "type": "record",
285+ | "name": "episodes",
286+ | "namespace": "testing.hive.avro.serde",
287+ | "fields": [
288+ | {
289+ | "name": "title",
290+ | "type": "string",
291+ | "doc": "episode title"
292+ | },
293+ | {
294+ | "name": "air_date",
295+ | "type": "string",
296+ | "doc": "initial date"
297+ | },
298+ | {
299+ | "name": "doctor",
300+ | "type": "int",
301+ | "doc": "main actor playing the Doctor in episode"
302+ | }
303+ | ]
304+ | }'
305+ |)
306+ """ .stripMargin.cmd,
307+ // WORKAROUND: Required to pass schema to SerDe for partitioned tables.
308+ // TODO: Pass this automatically from the table to partitions.
309+ s """
310+ |ALTER TABLE episodes_part SET SERDEPROPERTIES (
311+ | 'avro.schema.literal'='{
312+ | "type": "record",
313+ | "name": "episodes",
314+ | "namespace": "testing.hive.avro.serde",
315+ | "fields": [
316+ | {
317+ | "name": "title",
318+ | "type": "string",
319+ | "doc": "episode title"
320+ | },
321+ | {
322+ | "name": "air_date",
323+ | "type": "string",
324+ | "doc": "initial date"
325+ | },
326+ | {
327+ | "name": "doctor",
328+ | "type": "int",
329+ | "doc": "main actor playing the Doctor in episode"
330+ | }
331+ | ]
332+ | }'
333+ |)
334+ """ .stripMargin.cmd,
335+ s " INSERT OVERWRITE TABLE episodes_part PARTITION (doctor_pt=1) SELECT title, air_date, doctor FROM episodes " .cmd
336+ )
273337 )
274338
275339 hiveQTestUtilTables.foreach(registerTestTable)
0 commit comments