-
Notifications
You must be signed in to change notification settings - Fork 29
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
Avro 0.16 wrongly fails on date examples #61
Comments
@lerouxrgd Indeed, it seems that the apache-avro project on GitHub does not use the issue tracking system of GitHub. After some clicking around, it seems that all issues are managed in Jira by the Apache Software Foundation ASF, which can be found here. At the top of that page, you can find a self serve sign up link. After you have an account, I hope you can submit that issue there. I've requested an account, but it seems to take some time... FYI I had a similar issue as the one you've described. Below schema, although fine in Kafka, could not be parsed in {
"type": "record",
"name": "TimeManagement",
"namespace": "eu.driver.model.sim.config",
"doc": "The time management message can be used for informing connected applications on time progression and changes. *Copyright (C) 2019-2020 XVR Simulation B.V., Delft, The Netherlands, Martijn Hendriks <hendriks @ xvrsim.com>. This file is licensed under the MIT license : https://github.com/DRIVER-EU/avro-schemas/blob/master/LICENSE*",
"fields": [
{
"name": "state",
"type": {
"type": "enum",
"name": "TimeState",
"doc": "Initialization – preparing for the actual start of the simulation time; Started – the simulation time is started; Paused – the simulation time is paused; Stopped – the simulation time is stopped; Reset – the simulation time is reset",
"symbols": [
"Initialization",
"Started",
"Paused",
"Stopped",
"Reset"
]
},
"doc": "State the time is currently in"
},
{
"name": "tags",
"type": [
"null",
{
"type": "map",
"values": "string"
}
],
"doc": "Optional map containing session time specific information: key – unique name of the specific property; value – value of that property",
"default": null
},
{
"name": "timestamp",
"type": [
"null",
"long"
],
"doc": "Optional UNIX Epoch time in milliseconds marking the time the update was or needs to be performed",
"default": null,
"logicalType": "timestamp-millis"
},
{
"name": "simulationTime",
"type": [
"null",
"long"
],
"doc": "Optional UNIX Epoch time in milliseconds marking the fictive date and time the session should run with",
"default": null,
"logicalType": "timestamp-millis"
},
{
"name": "simulationSpeed",
"type": [
"null",
"float"
],
"doc": "Optional speed factor this session wants to run a simulation. The range of this speed factor is [0, infinity)",
"default": null
}
]
} |
Hello, |
Yes! This must be fixed in main branch!
Please test it before we make a release!
…On Tue, 20 Feb 2024 at 18:28, Romain Leroux ***@***.***> wrote:
Hello,
I have actually opened an issue on their Jira:
https://issues.apache.org/jira/browse/AVRO-3928
As far as I know @martin-g <https://github.com/martin-g> fixed it
already, now we just have to wait for a new release of the Rust SDK.
—
Reply to this email directly, view it on GitHub
<#61 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABYUQSWSZ2IDGNPI525TJ3YUTFMXAVCNFSM6AAAAABB3KLDUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJUGU4TAMJWHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@martin-g Do you expect that this fix will also solve my issue? |
Please test your use case against |
I have tried to test it by updating [dependencies]
apache-avro = { version = "0.17", features = ["derive"] }
[patch.crates-io]
apache-avro = { git = "https://github.com/apache/avro.git" } However there are some breaking changes to figure out first. |
Giving it a quick try, it looks like |
@martin-g If @erikvullings As for your example it now generates the following Rust code: /// Initialization – preparing for the actual start of the simulation time; Started – the simulation time is started; Paused – the simulation time is paused; Stopped – the simulation time is stopped; Reset – the simulation time is reset
#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Clone, serde::Deserialize, serde::Serialize)]
pub enum TimeState {
Initialization,
Started,
Paused,
Stopped,
Reset,
}
/// The time management message can be used for informing connected applications on time progression and changes. *Copyright (C) 2019-2020 XVR Simulation B.V., Delft, The Netherlands, Martijn Hendriks <hendriks @ xvrsim.com>. This file is licensed under the MIT license : https://github.com/DRIVER-EU/avro-schemas/blob/master/LICENSE*
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
pub struct TimeManagement {
pub state: TimeState,
#[serde(default = "default_timemanagement_tags")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(default = "default_timemanagement_timestamp")]
pub timestamp: Option<i64>,
#[serde(rename = "simulationTime")]
#[serde(default = "default_timemanagement_simulation_time")]
pub simulation_time: Option<i64>,
#[serde(rename = "simulationSpeed")]
#[serde(default = "default_timemanagement_simulation_speed")]
pub simulation_speed: Option<f32>,
}
#[inline(always)]
fn default_timemanagement_tags() -> Option<::std::collections::HashMap<String, String>> { None }
#[inline(always)]
fn default_timemanagement_timestamp() -> Option<i64> { None }
#[inline(always)]
fn default_timemanagement_simulation_time() -> Option<i64> { None }
#[inline(always)]
fn default_timemanagement_simulation_speed() -> Option<f32> { None } Does that look good to you ? |
By the way, I think that the timestamp fields should be defined as: {
"name": "timestamp",
"type": [
"null",
{"type": "long", "logicalType": "timestamp-millis"}
],
"doc": "Optional UNIX Epoch time in milliseconds marking the time the update was or needs to be performed",
"default": null
} Instead of what you currently have, that is: {
"name": "timestamp",
"type": [
"null",
"long"
],
"doc": "Optional UNIX Epoch time in milliseconds marking the time the update was or needs to be performed",
"default": null,
"logicalType": "timestamp-millis"
} |
@lerouxrgd Is there a failing test in branch |
I am trying with the following schema: {
"type": "record",
"name": "Decimals",
"fields": [ {
"name": "a_decimal",
"type": {"type": "bytes", "logicalType": "decimal", "precision": 4, "scale": 2}
}, {
"name": "a_big_decimal",
"type": ["null", {"type": "bytes", "logicalType": "big-decimal"}],
"default": null
} ]
} Which for now generates the following Rust code: #[derive(Debug, PartialEq, Eq, Clone, serde::Deserialize, serde::Serialize)]
pub struct Decimals {
pub a_decimal: apache_avro::Decimal,
#[serde(default = "default_decimals_a_big_decimal")]
pub a_big_decimal: Option<apache_avro::BigDecimal>,
}
#[inline(always)]
fn default_decimals_a_big_decimal() -> Option<apache_avro::BigDecimal> { None } However there are a few things that prevent it from compiling:
|
What do you think about adding |
I am not sure whether |
That's pretty much what is done in the diff --git a/tests/schemas/decimals.avsc b/tests/schemas/decimals.avsc
new file mode 100644
index 0000000..d3c09a5
--- /dev/null
+++ b/tests/schemas/decimals.avsc
@@ -0,0 +1,12 @@
+{
+ "type": "record",
+ "name": "Decimals",
+ "fields": [ {
+ "name": "a_decimal",
+ "type": {"type": "bytes", "logicalType": "decimal", "precision": 4, "scale": 2}
+ }, {
+ "name": "a_big_decimal",
+ "type": ["null", {"type": "bytes", "logicalType": "big-decimal"}],
+ "default": null
+ } ]
+}
diff --git a/tests/schemas/decimals.rs b/tests/schemas/decimals.rs
new file mode 100644
index 0000000..974d3c4
--- /dev/null
+++ b/tests/schemas/decimals.rs
@@ -0,0 +1,10 @@
+
+#[derive(Debug, PartialEq, Eq, Clone, serde::Deserialize, serde::Serialize)]
+pub struct Decimals {
+ pub a_decimal: apache_avro::Decimal,
+ #[serde(default = "default_decimals_a_big_decimal")]
+ pub a_big_decimal: Option<apache_avro::BigDecimal>,
+}
+
+#[inline(always)]
+fn default_decimals_a_big_decimal() -> Option<apache_avro::BigDecimal> { None }
\ No newline at end of file
diff --git a/tests/schemas/mod.rs b/tests/schemas/mod.rs
index a7a6ee8..7767d34 100644
--- a/tests/schemas/mod.rs
+++ b/tests/schemas/mod.rs
@@ -1,4 +1,5 @@
pub mod complex;
+pub mod decimals;
pub mod enums;
pub mod enums_casing;
pub mod enums_multiline_doc; |
OK! Thanks! If you want you can push this failing test to |
Sure, I have force pushed it to |
I think I fixed all issues!
|
Thanks for the fixes @martin-g ! Besides, I was thinking that maybe |
I think it makes a perfect sense! |
Requested-at: lerouxrgd/rsgen-avro#61 (comment) Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Requested-at: lerouxrgd/rsgen-avro#61 (comment) Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> (cherry picked from commit 64c1198)
Done! What about the time/date/duration types ? |
Awesome, thanks ! |
@lerouxrgd Thanks for the feedback on my schema! Indeed, when rewriting the schema as you suggested (which also made complete sense to me), it already works with the current |
@martin-g Actually I could think of one more re-export that would be useful, that is In #38 we discussed using Ideally |
I will take a look soon! |
Looks good! |
Requested-at: lerouxrgd/rsgen-avro#61 (comment) Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
With release
|
Requested-at: lerouxrgd/rsgen-avro#61 (comment) Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
It says:
default's value type of field "birthday" in "DateLogicalType" must be "{\"type\":\"int\",\"logicalType\":\"date\"}"
However this one is fine:
@martin-g Do you know where I should report this ?
Originally posted by @lerouxrgd in #60 (comment)
The text was updated successfully, but these errors were encountered: