This is an automated email from the ASF dual-hosted git repository.
ssiddiqi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push:
new 4b1eac1 [MINOR] Adding validation check for division-by-zero when
setting number of columns in frame constructor
4b1eac1 is described below
commit 4b1eac101f8167aead4999f5804a28b83fafa040
Author: Shafaq Siddiqi <[email protected]>
AuthorDate: Tue Feb 15 16:30:08 2022 +0100
[MINOR] Adding validation check for division-by-zero when setting number of
columns in frame constructor
---
.../org/apache/sysds/runtime/instructions/cp/DataGenCPInstruction.java | 2 +-
.../org/apache/sysds/runtime/instructions/spark/RandSPInstruction.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git
a/src/main/java/org/apache/sysds/runtime/instructions/cp/DataGenCPInstruction.java
b/src/main/java/org/apache/sysds/runtime/instructions/cp/DataGenCPInstruction.java
index 865174d..971274d 100644
---
a/src/main/java/org/apache/sysds/runtime/instructions/cp/DataGenCPInstruction.java
+++
b/src/main/java/org/apache/sysds/runtime/instructions/cp/DataGenCPInstruction.java
@@ -355,7 +355,7 @@ public class DataGenCPInstruction extends
UnaryCPInstruction {
}
else {
String[] data =
frame_data.split(DataExpression.DELIM_NA_STRING_SEP);
- int rowLength = data.length/lrows;
+ int rowLength = (lrows > 0)?data.length/lrows:0;
if(data.length != schemaLength && data.length >
1 && rowLength != schemaLength)
throw new DMLRuntimeException(
"data values should be equal to
number of columns," + " or a single values for all columns");
diff --git
a/src/main/java/org/apache/sysds/runtime/instructions/spark/RandSPInstruction.java
b/src/main/java/org/apache/sysds/runtime/instructions/spark/RandSPInstruction.java
index 567f560..b3c9424 100644
---
a/src/main/java/org/apache/sysds/runtime/instructions/spark/RandSPInstruction.java
+++
b/src/main/java/org/apache/sysds/runtime/instructions/spark/RandSPInstruction.java
@@ -993,7 +993,7 @@ public class RandSPInstruction extends UnarySPInstruction {
}
else {
String[] data =
_data.split(DataExpression.DELIM_NA_STRING_SEP);
- int rowLength = data.length/(int)_rlen;
+ int rowLength = ((int)_rlen >
0)?data.length/(int)_rlen:0;
if(data.length != _schema.length && data.length
> 1 && rowLength != _schema.length)
throw new DMLRuntimeException("data
values should be equal "
+ "to number of columns, or a
single values for all columns");