avro-serde-php icon indicating copy to clipboard operation
avro-serde-php copied to clipboard

How to define logicalTypes

Open BeyerJC opened this issue 3 years ago • 7 comments

Hi everyone !

I'm trying to define a field as "timestamp-millis" and i can see that this definition does exist in the code as type long with a logical type. But i dont see any usage of it in the tests and it seems to be unavailable as type in the annotations Avro\AvroType.

Can anyone give me an example on how to define it ? If its not available right now, i can work on a PR adding it.

BeyerJC avatar Oct 11 '21 12:10 BeyerJC

Hy @WhiteRabbitDE how are you trying to define the field?

You could use the Schema::timestampMillis() method. But if you're interested in defining it through annotations, I believe it would be needed to implement it.

A good starting point could be the FlixTech\AvroSerializer\Objects\Schema\Generation\TypeMapper class.

xico42 avatar Oct 25 '21 18:10 xico42

Hey @fcoedno ,

yes. I try to define it using annotations. If its not available yet, i will work on a PR. Are there also any plans right now to support attributes ? If not, i know what to work on afterwards ;-)

BeyerJC avatar Oct 25 '21 18:10 BeyerJC

About supporting php 8 attributes, I've implemented it on a local fork. I'm just finishing up some details to submit a PR

xico42 avatar Oct 25 '21 19:10 xico42

Regarding the logical types, it is still not available.

xico42 avatar Oct 25 '21 19:10 xico42

Great news ! Thanks for your work and this library ! I will look into the logical types and will work on a PR.

BeyerJC avatar Oct 25 '21 19:10 BeyerJC

@WhiteRabbitDE I've just opened the php8 attributes PR (#64). But I've implemented it only for php >= 8.1, because php 8.0 does not support nested attributes.

xico42 avatar Oct 25 '21 19:10 xico42

It may need some extra work for it to be ready, so feel free to help me out on that PR ;)

xico42 avatar Oct 25 '21 19:10 xico42