Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logicalType support #29

Open
lukaszkorecki opened this issue Apr 14, 2017 · 4 comments
Open

logicalType support #29

lukaszkorecki opened this issue Apr 14, 2017 · 4 comments

Comments

@lukaszkorecki
Copy link

Hi! Thank you for the library, it's terribly useful (finally we can stop using JSON ;-))

I was wondering if logicalType property is supported - https://avro.apache.org/docs/1.8.0/spec.html#Logical+Types

From my quick experiments it looks like they don't work, or I'm simply doing something wrong:

(require '[abracad.avro :as avro])

(def schema
  (avro/parse-schema
   {:type :record
    :name "Thing"
    :fields [{:name "name", :type :string}
             {:name "timestamp" :logicalType "date" :type :int}]}))

(def ex
  { :name "Foo" :timestamp 1491306685 })

(->> (avro/binary-encoded schema ex)
     (avro/decode schema))

;; => {:name "Foo", :timestamp 1491306685}

if it's not supported, I'm happy to add support but I'd need a bit of help as to where should I start 👍

Thanks!

@llasram
Copy link
Member

llasram commented Apr 14, 2017

It is not currently supported -- logicalType post-dates the original implementation and just hasn't been added. So a PR would be great! I'd suggest trying to extend the existing "Avro readers" system for custom decoding of records to use the value of logicalType for custom decoding of non-record types as well, although the extra annotations described for the "decimal" type do complicate matters.

@lukaszkorecki
Copy link
Author

@llasram Awesome, thanks for the pointer. No promises about the time, but I will definitely set aside some time to work on this.

@gleisonsilva
Copy link

@lukaszkorecki Hello! Have you get along with "date" types already? I'm currently facing the need to serialize a Date value, but I'm not figuring out how to do that.

@lukaszkorecki
Copy link
Author

lukaszkorecki commented Sep 27, 2018

@gleisonsilva Hi! Unfortunately, I haven't - so far we've been delegating that to the application logic. We have a set of helper functions in our tiny Abracad wrapper which preprocesses/postprocesses timestamp fields when serializing/deserializing. We use unix timestamps everywhere and UTC as the timezone.
Now - our Avro usage is increasing (we've recently open-sourced our RabbitMQ framework https://github.com/nomnom-insights/nomnom.bunnicula which supports custom serializers/deserializers for publishers and consumers) so we will have to eventually tackle the timestamp serialization issue :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants