Giter VIP home page Giter VIP logo

confluentinc / avro Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apache/avro

12.0 12.0 20.0 12.2 MB

Mirror of Apache Avro

License: Apache License 2.0

Shell 0.45% CMake 0.36% C++ 8.93% M4 0.40% LLVM 0.11% Yacc 0.07% Python 7.28% Batchfile 0.02% C 13.96% C# 11.09% Java 44.73% HTML 1.07% CSS 0.05% JavaScript 4.74% Thrift 0.02% Perl 1.42% PHP 2.81% Ruby 2.44% Vim Script 0.04% Raku 0.01%

avro's People

Stargazers

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

Watchers

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

avro's Issues

Open To Outside Contributions?

Is this project open to outside contributions? I haven't been successful in my attempts to get .NET updates and improvements into the official Avro project (see PR #307 in the official Avro project). You already have a NuGet package which seems to have some traction (40k downloads at the time of this post). I would love to transfer some of my contributions to this project if you are open to them.

Allow reserved C# keywords as enum values

Hi , I have to use reserved C# keyword "in" as enum symbol (in for inch):

{
"name": "DimensionUnits",
"type": {
  "type": "enum",
  "name": "DimensionUnitOfMeasure",
  "symbols": [
    "mm",
    **"in"**
  ]
}

I can achieve that in avrogen.exe by adding @ before symbol name in CodeGen.cs: (line 309)

foreach (string symbol in enumschema.Symbols)
{
    var alwaysAllowedSymbol = symbol;
    if (CodeGenUtil.Instance.ReservedKeywords.Contains(symbol))
        alwaysAllowedSymbol = '@' + symbol;
    CodeMemberField field = new CodeMemberField(typeof(int), alwaysAllowedSymbol);
    ctd.Members.Add(field);
}

Can we add it to official source code? Thanks. If not, could you provide me with explanation (maybe I could figure it out).

Avro Timestamp

Hello, for my master thesis project, i'm generating mock data using kafka-connect and avro schema, but the timestamp field in kafka is generated in this way/Unix epoch i suppose: 8203758334795633000 with 19 digits, and some values are negative.
I tried to convert it using transforms=TimestampConverter but then i get this : "174673355-10-23 23:41:30.000228" , how can I generate normal timestamps I can deal with ?

This how i defined timestamp in avro schema:
{ "name": "Timestamp", "type": "long", "logicalType": "timestamp-millis" }

Value serialization error while parsing optional long type

Hi, I am trying to parse a long value into optional long type, but it gives an exception stating can't find a match for System.Double. If I include double in the type, then it works fine. Please find below details -

AVRO schema -
{ "name": "xyz", "type": ["long", "null"], "default": null, "logicalType": "timestamp-millis" }

Exception -
Avro.AvroException: Cannot find a match for System.Double in {"type":["long","null"]} in field ********* at Avro.Generic.DefaultWriter.WriteRecord(RecordSchema schema, Object value, Encoder encoder) at Confluent.SchemaRegistry.Serdes.GenericSerializerImpl.Serialize(String topic, GenericRecord data, Boolean isKey) at Confluent.SchemaRegistry.Serdes.AvroSerializer1.SerializeAsync(T value, SerializationContext context)
at Confluent.Kafka.Producer2.ProduceAsync(TopicPartition topicPartition, Message2 message)
--- End of inner exception stack trace ---`

I will really appreciate any inputs or workaround with this regard.

Default Values

Ur tool does not add default values to fields. For "Map" for example their is an error if u not filled some property

Logical Types in .NET

I've submitted a PR to apache/avro that supports logical types in .NET:
apache#492

Currently, in order to use the Avro serializer, a dependency on Confluent.Apache.Avro is required because of the required dependency on Confluent.SchemaRegistry.Serdes. The two versions can't be used side by side because they populate the same namespace.

I was wondering if the above PR could be considered for inclusion?

Serializing a GenericRecord does not write the top level Record's doc comment into the .avro file's schema

With Confluent.Apache.Avro v1.7.7.7

Given the following schema:

{
    "type": "record",
    "namespace": "com.example.foo",
    "name": "bar",
    "doc": "An example record doc field, which will be ignored by the DatumFileWriter.",
    "fields": [
        ...
    ]
}

If you create a GenericRecord using the above schema and populate the fields, then use the following code to persist it to an .avro file; the doc comment from the top level record is lost.

using var datumFileWriter = DataFileWriter<GenericRecord>.OpenWriter(datumWriter, writeStream);
                datumFileWriter.Append(record);
                datumFileWriter.Flush();

e.g. Result (Note, schema was extracted from within .avro file's contents and fields trimmed for brevity):

{"type":"record","name":"bar","namespace":"com.example.foo","fields":[...]}

According to the Avro spec (https://avro.apache.org/docs/current/spec.html#schema_record), record type should support doc comments; incidentally the python library we use for processing avro files works as expected and includes doc comments for records.

Pascal Property name

Can the avrogen.exe take a configuration from the command line or from avrogen.exe.config so that we can customise the Property name generated from tool?

C# naming convention for Property is PascalCasing, as the schema is shared across multiple languages it has been decided that the casing will be camelCasing in the schema.

How to access a nested record from generic record?

How can I get access to the actual field values when we have a generic record with a nested record as one of the fields?

{
fields: [
"someNestedRecord" : {
"someName": "someValue
}
]
}

Even the ToString() on generic record does not seem to be able to handle this?

GenericRecord not iterable

The GenericRecord class allows access to values by key, but it's not iterable, so you need to know the keys in advance. The Java implementation is the same.

But this seems like something you'd often want! Is there something I'm missing?

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.