Skip to content

Commit 759902c

Browse files
committed
fix(session-context): validate builder args and narrow module visibility
1 parent 60a0d74 commit 759902c

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎native/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod csv;
1919
mod errors;
2020
mod proto;
2121

22-
pub mod session_options {
22+
pub(crate) mod session_options {
2323
include!(concat!(env!("OUT_DIR"), "/datafusion_java.rs"));
2424
}
2525

‎src/main/java/org/apache/datafusion/SessionContextBuilder.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,18 @@ public final class SessionContextBuilder {
3838
SessionContextBuilder() {}
3939

4040
public SessionContextBuilder batchSize(int batchSize) {
41+
if (batchSize <= 0) {
42+
throw new IllegalArgumentException("batchSize must be positive, got " + batchSize);
43+
}
4144
this.batchSize = batchSize;
4245
return this;
4346
}
4447

4548
public SessionContextBuilder targetPartitions(int targetPartitions) {
49+
if (targetPartitions <= 0) {
50+
throw new IllegalArgumentException(
51+
"targetPartitions must be positive, got " + targetPartitions);
52+
}
4653
this.targetPartitions = targetPartitions;
4754
return this;
4855
}
@@ -61,6 +68,13 @@ public SessionContextBuilder informationSchema(boolean informationSchema) {
6168
* Cap the memory pool at {@code maxMemoryBytes}, reserving {@code fraction} of it for queries.
6269
*/
6370
public SessionContextBuilder memoryLimit(long maxMemoryBytes, double fraction) {
71+
if (maxMemoryBytes <= 0) {
72+
throw new IllegalArgumentException(
73+
"maxMemoryBytes must be positive, got " + maxMemoryBytes);
74+
}
75+
if (fraction <= 0.0 || fraction > 1.0) {
76+
throw new IllegalArgumentException("fraction must be in (0, 1], got " + fraction);
77+
}
6478
this.memoryLimitBytes = maxMemoryBytes;
6579
this.memoryLimitFraction = fraction;
6680
return this;

0 commit comments

Comments
 (0)