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

Feature/105 remove default features #109

Merged
merged 7 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 70 additions & 76 deletions serde_arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,90 +40,84 @@ arrow-38 = ["dep:arrow-array-38", "dep:arrow-schema-38", "dep:arrow-data-38", "d
arrow-37 = ["dep:arrow-array-37", "dep:arrow-schema-37", "dep:arrow-data-37", "dep:arrow-buffer-37"]

[dependencies]
bytemuck = "1"
bytemuck = { version = "1", default-features = false }
# TODO: make optional, only required for str -> date conversions
chrono = "0.4"
half = { version = "2", features = ["bytemuck"] }
serde = { version = "1.0", features = ["derive"] }

# arrow-version:insert: arrow-array-{version} = {{ package = "arrow-array", version = "{version}", optional = true }}{\n}arrow-buffer-{version} = {{ package = "arrow-buffer", version = "{version}", optional = true }}{\n}arrow-data-{version} = {{ package = "arrow-data", version="{version}", optional = true }}{\n}arrow-schema-{version} = {{ package = "arrow-schema", version = "{version}", optional = true }}{\n}
arrow-array-49 = { package = "arrow-array", version = "49", optional = true }
arrow-buffer-49 = { package = "arrow-buffer", version = "49", optional = true }
arrow-data-49 = { package = "arrow-data", version="49", optional = true }
arrow-schema-49 = { package = "arrow-schema", version = "49", optional = true }

arrow-array-48 = { package = "arrow-array", version = "48", optional = true }
arrow-buffer-48 = { package = "arrow-buffer", version = "48", optional = true }
arrow-data-48 = { package = "arrow-data", version="48", optional = true }
arrow-schema-48 = { package = "arrow-schema", version = "48", optional = true }

arrow-array-47 = { package = "arrow-array", version = "47", optional = true }
arrow-buffer-47 = { package = "arrow-buffer", version = "47", optional = true }
arrow-data-47 = { package = "arrow-data", version="47", optional = true }
arrow-schema-47 = { package = "arrow-schema", version = "47", optional = true }

arrow-array-46 = { package = "arrow-array", version = "46", optional = true }
arrow-buffer-46 = { package = "arrow-buffer", version = "46", optional = true }
arrow-data-46 = { package = "arrow-data", version="46", optional = true }
arrow-schema-46 = { package = "arrow-schema", version = "46", optional = true }

arrow-array-45 = { package = "arrow-array", version = "45", optional = true }
arrow-buffer-45 = { package = "arrow-buffer", version = "45", optional = true }
arrow-data-45 = { package = "arrow-data", version="45", optional = true }
arrow-schema-45 = { package = "arrow-schema", version = "45", optional = true }

arrow-array-44 = { package = "arrow-array", version = "44", optional = true }
arrow-buffer-44 = { package = "arrow-buffer", version = "44", optional = true }
arrow-data-44 = { package = "arrow-data", version="44", optional = true }
arrow-schema-44 = { package = "arrow-schema", version = "44", optional = true }

arrow-array-43 = { package = "arrow-array", version = "43", optional = true }
arrow-buffer-43 = { package = "arrow-buffer", version = "43", optional = true }
arrow-data-43 = { package = "arrow-data", version="43", optional = true }
arrow-schema-43 = { package = "arrow-schema", version = "43", optional = true }

arrow-array-42 = { package = "arrow-array", version = "42", optional = true }
arrow-buffer-42 = { package = "arrow-buffer", version = "42", optional = true }
arrow-data-42 = { package = "arrow-data", version="42", optional = true }
arrow-schema-42 = { package = "arrow-schema", version = "42", optional = true }

arrow-array-41 = { package = "arrow-array", version = "41", optional = true }
arrow-buffer-41 = { package = "arrow-buffer", version = "41", optional = true }
arrow-data-41 = { package = "arrow-data", version="41", optional = true }
arrow-schema-41 = { package = "arrow-schema", version = "41", optional = true }

arrow-array-40 = { package = "arrow-array", version = "40", optional = true }
arrow-buffer-40 = { package = "arrow-buffer", version = "40", optional = true }
arrow-data-40 = { package = "arrow-data", version="40", optional = true }
arrow-schema-40 = { package = "arrow-schema", version = "40", optional = true }

arrow-array-39 = { package = "arrow-array", version = "39", optional = true }
arrow-buffer-39 = { package = "arrow-buffer", version = "39", optional = true }
arrow-data-39 = { package = "arrow-data", version="39", optional = true }
arrow-schema-39 = { package = "arrow-schema", version = "39", optional = true }

arrow-array-38 = { package = "arrow-array", version = "38", optional = true }
arrow-buffer-38 = { package = "arrow-buffer", version = "38", optional = true }
arrow-data-38 = { package = "arrow-data", version="38", optional = true }
arrow-schema-38 = { package = "arrow-schema", version = "38", optional = true }

arrow-array-37 = { package = "arrow-array", version = "37", optional = true }
arrow-buffer-37 = { package = "arrow-buffer", version = "37", optional = true }
arrow-data-37 = { package = "arrow-data", version="37", optional = true }
arrow-schema-37 = { package = "arrow-schema", version = "37", optional = true }

arrow2-0-17 = { package = "arrow2", version = "0.17", optional = true }
arrow2-0-16 = { package = "arrow2", version = "0.16", optional = true }
chrono = { version = "0.4", features = ["std"], default-features = false }
half = { version = "2", features = ["bytemuck"], default-features = false }
serde = { version = "1.0", features = ["derive", "std"], default-features = false }

# arrow-version:insert: arrow-array-{version} = {{ package = "arrow-array", version = "{version}", optional = true, default-features = false }}
arrow-array-49 = { package = "arrow-array", version = "49", optional = true, default-features = false }
arrow-array-48 = { package = "arrow-array", version = "48", optional = true, default-features = false }
arrow-array-47 = { package = "arrow-array", version = "47", optional = true, default-features = false }
arrow-array-46 = { package = "arrow-array", version = "46", optional = true, default-features = false }
arrow-array-45 = { package = "arrow-array", version = "45", optional = true, default-features = false }
arrow-array-44 = { package = "arrow-array", version = "44", optional = true, default-features = false }
arrow-array-43 = { package = "arrow-array", version = "43", optional = true, default-features = false }
arrow-array-42 = { package = "arrow-array", version = "42", optional = true, default-features = false }
arrow-array-41 = { package = "arrow-array", version = "41", optional = true, default-features = false }
arrow-array-40 = { package = "arrow-array", version = "40", optional = true, default-features = false }
arrow-array-39 = { package = "arrow-array", version = "39", optional = true, default-features = false }
arrow-array-38 = { package = "arrow-array", version = "38", optional = true, default-features = false }
arrow-array-37 = { package = "arrow-array", version = "37", optional = true, default-features = false }

# arrow-version:insert: arrow-buffer-{version} = {{ package = "arrow-buffer", version = "{version}", optional = true, default-features = false }}
arrow-buffer-49 = { package = "arrow-buffer", version = "49", optional = true, default-features = false }
arrow-buffer-48 = { package = "arrow-buffer", version = "48", optional = true, default-features = false }
arrow-buffer-47 = { package = "arrow-buffer", version = "47", optional = true, default-features = false }
arrow-buffer-46 = { package = "arrow-buffer", version = "46", optional = true, default-features = false }
arrow-buffer-45 = { package = "arrow-buffer", version = "45", optional = true, default-features = false }
arrow-buffer-44 = { package = "arrow-buffer", version = "44", optional = true, default-features = false }
arrow-buffer-43 = { package = "arrow-buffer", version = "43", optional = true, default-features = false }
arrow-buffer-42 = { package = "arrow-buffer", version = "42", optional = true, default-features = false }
arrow-buffer-41 = { package = "arrow-buffer", version = "41", optional = true, default-features = false }
arrow-buffer-40 = { package = "arrow-buffer", version = "40", optional = true, default-features = false }
arrow-buffer-39 = { package = "arrow-buffer", version = "39", optional = true, default-features = false }
arrow-buffer-38 = { package = "arrow-buffer", version = "38", optional = true, default-features = false }
arrow-buffer-37 = { package = "arrow-buffer", version = "37", optional = true, default-features = false }

# arrow-version:insert: arrow-data-{version} = {{ package = "arrow-data", version="{version}", optional = true, default-features = false }}
arrow-data-49 = { package = "arrow-data", version="49", optional = true, default-features = false }
arrow-data-48 = { package = "arrow-data", version="48", optional = true, default-features = false }
arrow-data-47 = { package = "arrow-data", version="47", optional = true, default-features = false }
arrow-data-46 = { package = "arrow-data", version="46", optional = true, default-features = false }
arrow-data-45 = { package = "arrow-data", version="45", optional = true, default-features = false }
arrow-data-44 = { package = "arrow-data", version="44", optional = true, default-features = false }
arrow-data-43 = { package = "arrow-data", version="43", optional = true, default-features = false }
arrow-data-42 = { package = "arrow-data", version="42", optional = true, default-features = false }
arrow-data-41 = { package = "arrow-data", version="41", optional = true, default-features = false }
arrow-data-40 = { package = "arrow-data", version="40", optional = true, default-features = false }
arrow-data-39 = { package = "arrow-data", version="39", optional = true, default-features = false }
arrow-data-38 = { package = "arrow-data", version="38", optional = true, default-features = false }
arrow-data-37 = { package = "arrow-data", version="37", optional = true, default-features = false }

# arrow-version:insert: arrow-schema-{version} = {{ package = "arrow-schema", version = "{version}", optional = true, default-features = false }}{\n}
arrow-schema-49 = { package = "arrow-schema", version = "49", optional = true, default-features = false }
arrow-schema-48 = { package = "arrow-schema", version = "48", optional = true, default-features = false }
arrow-schema-47 = { package = "arrow-schema", version = "47", optional = true, default-features = false }
arrow-schema-46 = { package = "arrow-schema", version = "46", optional = true, default-features = false }
arrow-schema-45 = { package = "arrow-schema", version = "45", optional = true, default-features = false }
arrow-schema-44 = { package = "arrow-schema", version = "44", optional = true, default-features = false }
arrow-schema-43 = { package = "arrow-schema", version = "43", optional = true, default-features = false }
arrow-schema-42 = { package = "arrow-schema", version = "42", optional = true, default-features = false }
arrow-schema-41 = { package = "arrow-schema", version = "41", optional = true, default-features = false }
arrow-schema-40 = { package = "arrow-schema", version = "40", optional = true, default-features = false }
arrow-schema-39 = { package = "arrow-schema", version = "39", optional = true, default-features = false }
arrow-schema-38 = { package = "arrow-schema", version = "38", optional = true, default-features = false }
arrow-schema-37 = { package = "arrow-schema", version = "37", optional = true, default-features = false }

arrow2-0-17 = { package = "arrow2", version = "0.17", optional = true, default-features = false }
arrow2-0-16 = { package = "arrow2", version = "0.16", optional = true, default-features = false }

[dev-dependencies]
anyhow = "1"
chrono = { version = "0.4", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
chrono = { version = "0.4", features = ["serde"], default-features = false }
serde = { version = "1", features = ["derive", "std"], default-features = false }
serde_json = "1"
rand = "0.8"

# for benchmarks
# arrow-version:replace: arrow-json-{version} = {{ package = "arrow-json", version = "{version}" }}
arrow-json-49 = { package = "arrow-json", version = "49" }
criterion = "0.4"
arrow2_convert = "0.5.0"
arrow2_convert = "0.5.0"
12 changes: 6 additions & 6 deletions serde_arrow/src/internal/deserialization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1664,9 +1664,9 @@ impl Instruction for EmitDate64NaiveStr {
i64::from_ne_bytes(buffers.u64[self.buffer][positions[self.position]].to_ne_bytes());
positions[self.position] += 1;

// TODO: update with chrono 0.5
#[allow(deprecated)]
let val = NaiveDateTime::from_timestamp(val / 1000, (val % 1000) as u32 * 100_000);
let Some(val) = NaiveDateTime::from_timestamp_opt(val / 1000, (val % 1000) as u32 * 100_000) else {
fail!("Unsupported timestamp value: {val}");
};

// NOTE: chrono documents that Debug, not Display, can be parsed
Ok((self.next, Some(format!("{:?}", val).into())))
Expand All @@ -1690,9 +1690,9 @@ impl Instruction for EmitDate64UtcStr {
i64::from_ne_bytes(buffers.u64[self.buffer][positions[self.position]].to_ne_bytes());
positions[self.position] += 1;

// TODO: update with chrono 0.5
#[allow(deprecated)]
let val = Utc.timestamp(val / 1000, (val % 1000) as u32 * 100_000);
let Some(val) = Utc.timestamp_opt(val / 1000, (val % 1000) as u32 * 100_000).earliest() else {
fail!("Unsupported timestamp value: {val}");
};

// NOTE: chrono documents that Debug, not Display, can be parsed
Ok((self.next, Some(format!("{:?}", val).into())))
Expand Down
11 changes: 10 additions & 1 deletion x.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ def check_cargo_toml():
)

for component in ["arrow-array", "arrow-schema", "arrow-data", "arrow-buffer"]:
expected_dep = {"package": component, "version": version, "optional": True}
expected_dep = {
"package": component,
"version": version,
"optional": True,
"default-features": False,
}
actual_dep = config["dependencies"].get(f"{component}-{version}")

if actual_dep is None:
Expand All @@ -260,6 +265,10 @@ def check_cargo_toml():
f"Expected: {expected_dep}, found: {actual_dep}"
)

for name, dep in config["dependencies"].items():
if dep.get("default-features", True):
raise ValueError(f"Default features for {name} not deactivated")


@cmd(help="Run the benchmarks")
def bench():
Expand Down