Giter Club home page Giter Club logo

avro-patches's People

Contributors

ecopoesis avatar filipebarros avatar joshbranham avatar kphelps avatar tjwp avatar will89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avro-patches's Issues

include support for doc strings AVRO-2001

Thanks for creating this gem! This repo has been very useful rather than waiting for upstream patches to make it into avro.

I understand that this patch might not be needed when upstream avro is > 1.8.2. However, is it possible to include AVRO-2001 as part of this gem? I put a lot of effort to document fields in my schemas and it's a shame that they get stripped off when they make it into my schema registry

schema validator does not handle Unions correctly

As per Avro specification:
https://avro.apache.org/docs/1.8.2/spec.html#json_encoding

unions in json-format records should be encoded as a single object containing a single property where its name should be the tag-type refering to the union definition and its value being of that type.

Currently validate_union just iterates through all member types and uses the first that fits.

given the following schema

{
    "type":"record",
    "name":"ShouldSucceed",
    "namespace":"com.scigility.schemadrivenload",
    "fields":[
        {"name":"a","type":"int"},
        {"name":"b","type":"string"},
        {"name":"c","type":"boolean"},
        {"name":"d","type":["null","string"]}
    ]
}

this should be valid:

{"a":1,"b":"","c":true,"d":{"string":""}}

but leads to an error

at .d expected union of ['null', 'string'], got record with value {"string"=>""}

whereas

{"a":1,"b":"","c":true,"d":"asdf"}

should be rejected but isn't.

Issue when encoding LogicalTypes::TimestampMillis

Hello,

I've encountered an issue with encoding and the timestamp-millis logical type - when we use that logical type, throughout our codebase we've already converted the underlying Time or DateTime value to a Numeric, so it fails when trying to call to_time on it when encoding: https://github.com/salsify/avro-patches/blob/master/lib/avro-patches/logical_types/logical_types.rb#L19

Would it be possible to add a guard in this encode method which just returns the value itself if it is already 'encoded'? Something like:

module Avro
  module LogicalTypes
    module TimestampMillis
      def self.encode(value)
        return value if value.kind_of?(Numeric)

        time = value.to_time
        time.to_i * 1000 + time.usec / 1000
      end
    end
  end
end

Cheers,
Stefan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.