   (for [subfield (field-names record-schema)]
     (str prefix "." subfield)))
 
-(defn field-names [parsed-schema]
+(defn field-names [^Schema parsed-schema]
  (->> (.getFields parsed-schema)
-       (map (fn [field]
-              (let [type (.getType (.schema field))]
+       (map (fn [^Schema$Field field]
+              (let [type (.getType ^{:tag Schema} (.schema field))]
                 (cond
                  (= type Schema$Type/RECORD) (prefixed-names (.schema field) (.name field))
                  ;; pig only supports union of null, <type>.
                  (= type Schema$Type/UNION)  (let [record-fields (->> (.getTypes (.schema field))
-                                                                      (filter #(= (.getType %) Schema$Type/RECORD))
+                                                                      (filter #(= (.getType ^{:tag Schema} %) Schema$Type/RECORD))
                                                                       (map (fn [rec] (prefixed-names rec (.name field)))))]
                                                (if (empty? record-fields) [(.name field)]
                                                    record-fields))

       flatten
       vec))

(defn parse-schema [s] (.parse (Schema$Parser.) s))

(defmethod pigpen.pig/native->clojure org.apache.avro.util.Utf8 [value]
  (str value))

            [pigpen.raw :as raw]
            [pigpen.core :as pig])
  (:import [org.apache.avro
            Schema
            Schema$Field
            Schema$Type
            Schema$Parser
            SchemaNormalization]
           [org.apache.avro.file DataFileReader]
           [org.apache.avro.specific SpecificDatumReader]
           [org.apache.avro.generic GenericData$Record]
           [pigpen.local PigPenLocalLoader]))

(set! *warn-on-reflection* true)
