This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sedona-spatialbench.git

commit 89fbca10530c18391cae2de9a3153451aec18efc
Author: Pranav Toggi <[email protected]>
AuthorDate: Fri Aug 15 16:18:22 2025 -0700

    [EWT-3175] Fix failing integration tests (#6)
---
 spatialbench-arrow/src/lib.rs       |  24 ++++++++++++------------
 spatialbench/data/sf-v1/trip.tbl.gz | Bin 268486 -> 226051 bytes
 spatialbench/src/generators.rs      |  15 +++++++++++----
 spatialbench/src/lib.rs             |  10 +++++-----
 4 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/spatialbench-arrow/src/lib.rs b/spatialbench-arrow/src/lib.rs
index 6439361..0ccceb9 100644
--- a/spatialbench-arrow/src/lib.rs
+++ b/spatialbench-arrow/src/lib.rs
@@ -9,8 +9,8 @@
 //! # use spatialbench::generators::TripGenerator;
 //! # use spatialbench_arrow::TripArrow;
 //! # use arrow::util::pretty::pretty_format_batches;
-//! // Create a SF=1 generator for the LineItem table
-//! let generator = TripGenerator::new(1.0, 1, 1);
+//! // Create a SF=0.01 generator for the LineItem table
+//! let generator = TripGenerator::new(0.01, 1, 1);
 //! let mut arrow_generator = TripArrow::new(generator)
 //!   .with_batch_size(10);
 //! // The generator is a Rust iterator, producing RecordBatch
@@ -21,16 +21,16 @@
 //!   
"+-----------+-----------+-------------+--------------+--------------+---------------+---------+---------+---------------+------------+--------------------------------------------+--------------------------------------------+",
 //!   "| t_tripkey | t_custkey | t_driverkey | t_vehiclekey | t_pickuptime | 
t_dropofftime | t_fare  | t_tip   | t_totalamount | t_distance | t_pickuploc    
                            | t_dropoffloc                               |",
 //!   
"+-----------+-----------+-------------+--------------+--------------+---------------+---------+---------+---------------+------------+--------------------------------------------+--------------------------------------------+",
-//!   "| 1         | 21425     | 47          | 46           | 1997-07-24   | 
1997-07-24    | 0.00034 | 0.00002 | 0.00037       | 0.00014    | 
010100000000000000009f65c000000000008056c0 | 
01010000003c13323f719f65c0c62bcff1f28856c0 |",
-//!   "| 2         | 17012     | 66          | 65           | 1997-12-24   | 
1997-12-24    | 0.00003 | 0.00000 | 0.00004       | 0.00001    | 
010100000000000000800165c000000000001835c0 | 
0101000000ed03047c0f0165c00ee6b7aa721735c0 |",
-//!   "| 3         | 4454      | 68          | 67           | 1993-06-27   | 
1993-06-27    | 0.00000 | 0.00000 | 0.00000       | 0.00000    | 
010100000000000000007265c000000000809953c0 | 
0101000000336b00b00e7265c02f695d509e9953c0 |",
-//!   "| 4         | 3875      | 82          | 81           | 1996-08-02   | 
1996-08-02    | 0.00005 | 0.00000 | 0.00005       | 0.00002    | 
010100000000000000800f56c00000000000c63bc0 | 
01010000004a916d7e111056c0621ccaa6fdcb3bc0 |",
-//!   "| 5         | 23027     | 9           | 8            | 1996-08-23   | 
1996-08-23    | 0.00002 | 0.00000 | 0.00003       | 0.00001    | 
010100000000000000406460c00000000000da4640 | 
0101000000acb0a6a1ae6460c0e1a5886c17db4640 |",
-//!   "| 6         | 4573      | 41          | 40           | 1994-11-16   | 
1994-11-16    | 0.00003 | 0.00000 | 0.00003       | 0.00001    | 
010100000000000000002666c000000000806f40c0 | 
01010000006100a6303e2666c09f84c465c06d40c0 |",
-//!   "| 7         | 28319     | 60          | 59           | 1996-01-20   | 
1996-01-20    | 0.00000 | 0.00000 | 0.00000       | 0.00000    | 
010100000000000000002963c00000000000e040c0 | 
010100000000000000002963c00000000000e040c0 |",
-//!   "| 8         | 23288     | 32          | 31           | 1995-01-09   | 
1995-01-10    | 0.00003 | 0.00000 | 0.00003       | 0.00001    | 
010100000000000000008056c000000000c03955c0 | 
01010000007fcc20a00d8156c0daf2ab4bd83955c0 |",
-//!   "| 9         | 17744     | 100         | 99           | 1993-10-13   | 
1993-10-13    | 0.00005 | 0.00001 | 0.00007       | 0.00003    | 
010100000000000000005366c00000000000e050c0 | 
010100000065523404e75266c045ff5c8406e250c0 |",
-//!   "| 10        | 11800     | 98          | 97           | 1994-11-08   | 
1994-11-08    | 0.00001 | 0.00000 | 0.00001       | 0.00000    | 
010100000000000000008066c000000000c07456c0 | 
01010000001ded0e6fe27f66c001744f41837456c0 |",
+//!   "| 1         | 215       | 1           | 1            | 1997-07-24   | 
1997-07-24    | 0.00034 | 0.00002 | 0.00037       | 0.00014    | 
010100000000000000009f65c000000000008056c0 | 
0101000000ea6f323f719f65c0a190cff1f28856c0 |",
+//!   "| 2         | 172       | 1           | 1            | 1997-12-24   | 
1997-12-24    | 0.00003 | 0.00000 | 0.00004       | 0.00001    | 
010100000000000000800165c000000000001835c0 | 
01010000007707047c0f0165c0e360c2aa721735c0 |",
+//!   "| 3         | 46        | 1           | 1            | 1993-06-27   | 
1993-06-27    | 0.00000 | 0.00000 | 0.00000       | 0.00000    | 
010100000000000000007265c000000000809953c0 | 
0101000000123a01b00e7265c0fc9862509e9953c0 |",
+//!   "| 4         | 40        | 1           | 1            | 1996-08-02   | 
1996-08-02    | 0.00005 | 0.00000 | 0.00005       | 0.00002    | 
010100000000000000800f56c00000000000c63bc0 | 
01010000005c186d7e111056c0435fb4a6fdcb3bc0 |",
+//!   "| 5         | 232       | 1           | 1            | 1996-08-23   | 
1996-08-23    | 0.00002 | 0.00000 | 0.00003       | 0.00001    | 
010100000000000000406460c00000000000da4640 | 
01010000003da9a3a1ae6460c00036836c17db4640 |",
+//!   "| 6         | 46        | 1           | 1            | 1994-11-16   | 
1994-11-16    | 0.00003 | 0.00000 | 0.00003       | 0.00001    | 
010100000000000000002666c000000000806f40c0 | 
01010000009fbda7303e2666c0cdb6cb65c06d40c0 |",
+//!   "| 7         | 284       | 1           | 1            | 1996-01-20   | 
1996-01-20    | 0.00000 | 0.00000 | 0.00000       | 0.00000    | 
010100000000000000002963c00000000000e040c0 | 
010100000000000000002963c00000000000e040c0 |",
+//!   "| 8         | 233       | 1           | 1            | 1995-01-09   | 
1995-01-10    | 0.00003 | 0.00000 | 0.00003       | 0.00001    | 
010100000000000000008056c000000000c03955c0 | 
0101000000c0e91ba00d8156c06e03b14bd83955c0 |",
+//!   "| 9         | 178       | 1           | 1            | 1993-10-13   | 
1993-10-13    | 0.00005 | 0.00001 | 0.00007       | 0.00003    | 
010100000000000000005366c00000000000e050c0 | 
0101000000a6ef3504e75266c0448c538406e250c0 |",
+//!   "| 10        | 118       | 1           | 1            | 1994-11-08   | 
1994-11-08    | 0.00001 | 0.00000 | 0.00001       | 0.00000    | 
010100000000000000008066c000000000c07456c0 | 
01010000001459106fe27f66c08d065341837456c0 |",
 //!   
"+-----------+-----------+-------------+--------------+--------------+---------------+---------+---------+---------------+------------+--------------------------------------------+--------------------------------------------+"
 //! ]);
 //! ```
diff --git a/spatialbench/data/sf-v1/trip.tbl.gz 
b/spatialbench/data/sf-v1/trip.tbl.gz
index cd0c6ca..d1e895b 100644
Binary files a/spatialbench/data/sf-v1/trip.tbl.gz and 
b/spatialbench/data/sf-v1/trip.tbl.gz differ
diff --git a/spatialbench/src/generators.rs b/spatialbench/src/generators.rs
index 0963793..7bfc047 100644
--- a/spatialbench/src/generators.rs
+++ b/spatialbench/src/generators.rs
@@ -1092,7 +1092,9 @@ impl TripGeneratorIterator {
         let pickup_date = TPCHDate::new_with_time(pickup_date_value, 
pickup_time);
 
         // Get distance from KDE model (in miles with decimal precision)
-        let distance_value = self.distance_kde.generate(trip_key as u64);
+        let mut distance_value = self.distance_kde.generate(trip_key as u64);
+        // Hard code distance precision to 8 decimal places
+        distance_value = (distance_value * 100_000_000.0).round() / 
100_000_000.0;
         let distance = TPCHDecimal((distance_value * 100.0) as i64);
 
         // Pickup
@@ -1109,8 +1111,13 @@ impl TripGeneratorIterator {
         let angle: f64 = angle_rng.gen::<f64>() * std::f64::consts::TAU;
 
         // Dropoff via polar projection
-        let dropoff_x = pickup_x + distance_value * angle.cos();
-        let dropoff_y = pickup_y + distance_value * angle.sin();
+        let mut dropoff_x = pickup_x + distance_value * angle.cos();
+        let mut dropoff_y = pickup_y + distance_value * angle.sin();
+
+        // Hard code coordinate precision to 8 decimal places - milimeter 
level precision for WGS 84
+        dropoff_x = (dropoff_x * 100_000_000.0).round() / 100_000_000.0;
+        dropoff_y = (dropoff_y * 100_000_000.0).round() / 100_000_000.0;
+
         let dropoffloc = Point::new(dropoff_x, dropoff_y);
 
         let fare_per_mile = self.fare_per_mile_random.next_value() as f64;
@@ -1726,7 +1733,7 @@ mod tests {
         // Check first Trip
         let first = &trips[1];
         assert_eq!(first.t_tripkey, 2);
-        assert_eq!(first.to_string(), "2|172|1|1|1997-12-24 
08:47:14|1997-12-24 09:28:57|0.03|0.00|0.04|0.01|POINT(-168.046875 
-21.09375)|POINT(-168.03314018997426 -21.091593427559978)|");
+        assert_eq!(first.to_string(), "2|172|1|1|1997-12-24 
08:47:14|1997-12-24 09:28:57|0.03|0.00|0.04|0.01|POINT(-168.046875 
-21.09375)|POINT(-168.03314019 -21.09159343)|");
     }
 
     #[test]
diff --git a/spatialbench/src/lib.rs b/spatialbench/src/lib.rs
index 97b6876..812a0af 100644
--- a/spatialbench/src/lib.rs
+++ b/spatialbench/src/lib.rs
@@ -7,8 +7,8 @@
 //! # Example: TBL output format
 //! ```
 //! # use spatialbench::generators::TripGenerator;
-//! // Create Generator for the TRIP table at Scale Factor 1 (SF 1)
-//! let scale_factor = 1.0;
+//! // Create Generator for the TRIP table at Scale Factor 0.01 (SF 0.01)
+//! let scale_factor = 0.01;
 //! let part = 1;
 //! let num_parts = 1;
 //! let generator = TripGenerator::new(scale_factor, part, num_parts);
@@ -21,9 +21,9 @@
 //!    .collect::<Vec<_>>();
 //!  assert_eq!(
 //!   trips.join("\n"),"\
-//!     1|21425|47|46|1997-07-24 06:58:22|1997-07-24 
13:59:54|0.34|0.02|0.37|0.14|POINT(-172.96875 -90.0)|POINT(-172.98257407932567 
-90.13982815963308)|\n\
-//!     2|17012|66|65|1997-12-24 08:47:14|1997-12-24 
09:28:57|0.03|0.00|0.04|0.01|POINT(-168.046875 
-21.09375)|POINT(-168.03314018997426 -21.091593427559978)|\n\
-//!     3|4454|68|67|1993-06-27 13:27:07|1993-06-27 
13:34:51|0.00|0.00|0.00|0.00|POINT(-171.5625 
-78.3984375)|POINT(-171.56429290849482 -78.40028771516948)|"
+//!     1|215|1|1|1997-07-24 06:58:22|1997-07-24 
13:59:54|0.34|0.02|0.37|0.14|POINT(-172.96875 -90.0)|POINT(-172.98257408 
-90.13982816)|\n\
+//!     2|172|1|1|1997-12-24 08:47:14|1997-12-24 
09:28:57|0.03|0.00|0.04|0.01|POINT(-168.046875 -21.09375)|POINT(-168.03314019 
-21.09159343)|\n\
+//!     3|46|1|1|1993-06-27 13:27:07|1993-06-27 
13:34:51|0.00|0.00|0.00|0.00|POINT(-171.5625 -78.3984375)|POINT(-171.56429291 
-78.40028772)|"
 //!   );
 //! ```
 //!

Reply via email to