diff --git a/Cargo.lock b/Cargo.lock index ebf5f9d75b68c..53292d00da9a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10634,6 +10634,7 @@ version = "1.11.0-alpha" dependencies = [ "anyhow", "arrow-array 50.0.0", + "arrow-array 52.0.0", "arrow-schema 50.0.0", "assert_matches", "async-recursion", @@ -10785,7 +10786,9 @@ dependencies = [ "ahash 0.8.11", "anyhow", "arc-swap", + "arrow-array 48.0.1", "arrow-array 50.0.0", + "arrow-array 52.0.0", "arrow-buffer 48.0.1", "arrow-buffer 50.0.0", "arrow-buffer 52.0.0", @@ -11093,6 +11096,7 @@ dependencies = [ "anyhow", "apache-avro 0.16.0", "arrow-array 50.0.0", + "arrow-array 52.0.0", "arrow-row 50.0.0", "arrow-schema 50.0.0", "arrow-schema 52.0.0", @@ -11412,7 +11416,6 @@ dependencies = [ "icelake", "itertools 0.12.1", "jsonbb", - "lazy_static", "linkme", "madsim-tokio", "md5", diff --git a/src/batch/Cargo.toml b/src/batch/Cargo.toml index 2ca8ed1be4e77..ef4badfe07666 100644 --- a/src/batch/Cargo.toml +++ b/src/batch/Cargo.toml @@ -16,6 +16,7 @@ normal = ["workspace-hack"] [dependencies] anyhow = "1" arrow-array = { workspace = true } +arrow-array-iceberg = { workspace = true } arrow-schema = { workspace = true } assert_matches = "1" async-recursion = "1" diff --git a/src/common/Cargo.toml b/src/common/Cargo.toml index ba295b56f02ca..ae6f67faf3aac 100644 --- a/src/common/Cargo.toml +++ b/src/common/Cargo.toml @@ -18,6 +18,8 @@ ahash = "0.8" anyhow = "1" arc-swap = "1" arrow-array = { workspace = true } +arrow-array-deltalake = { workspace = true } +arrow-array-iceberg = { workspace = true } arrow-buffer = { workspace = true } arrow-buffer-deltalake = { workspace = true } arrow-buffer-iceberg = { workspace = true } diff --git a/src/connector/Cargo.toml b/src/connector/Cargo.toml index 257b930556c94..3d8bf618eca58 100644 --- a/src/connector/Cargo.toml +++ b/src/connector/Cargo.toml @@ -17,6 +17,7 @@ normal = ["workspace-hack"] anyhow = "1" apache-avro = { workspace = true } arrow-array = { workspace = true } +arrow-array-iceberg = { workspace = true } arrow-row = { workspace = true } arrow-schema = { workspace = true } arrow-schema-iceberg = { workspace = true } diff --git a/src/expr/impl/Cargo.toml b/src/expr/impl/Cargo.toml index 8e7cb36dc27fc..0f69c91e34162 100644 --- a/src/expr/impl/Cargo.toml +++ b/src/expr/impl/Cargo.toml @@ -50,7 +50,6 @@ hex = "0.4" icelake = { workspace = true } itertools = { workspace = true } jsonbb = { workspace = true } -lazy_static = "1.5.0" linkme = { version = "0.3", features = ["used_linker"] } md5 = "0.7" moka = { version = "0.12", features = ["sync"] } diff --git a/src/expr/impl/src/scalar/trigonometric.rs b/src/expr/impl/src/scalar/trigonometric.rs index f5ea625d7d2f3..b00078dc3bd5a 100644 --- a/src/expr/impl/src/scalar/trigonometric.rs +++ b/src/expr/impl/src/scalar/trigonometric.rs @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::f64::consts::PI; - -use lazy_static::lazy_static; use risingwave_common::types::F64; use risingwave_expr::function; @@ -98,73 +95,33 @@ pub fn atanh_f64(input: F64) -> F64 { f64::atanh(input.0).into() } +// Radians per degree, a.k.a. PI / 180 +static RADIANS_PER_DEGREE: f64 = 0.017_453_292_519_943_295; // Constants we use to get more accurate results. +// TODO: use lazy_static // Depend on the machine and have to be evaluated at runtime // See PSQL: https://github.com/postgres/postgres/blob/78ec02d612a9b69039ec2610740f738968fe144d/src/backend/utils/adt/float.c#L2024 -fn sind_30() -> f64 { - lazy_static! { - static ref SIND_30: f64 = f64::sin(30.0 * radians_per_degree()); - } - *SIND_30 -} - -fn one_minus_cosd_60() -> f64 { - lazy_static! { - static ref ONE_MINUS_COSD_60: f64 = 1.0 - f64::cos(60.0 * radians_per_degree()); - } - *ONE_MINUS_COSD_60 -} - -fn tand_45() -> f64 { - lazy_static! { - static ref TAND_45: f64 = f64::tan(45.0 * radians_per_degree()); - } - *TAND_45 -} - -fn cotd_45() -> f64 { - lazy_static! { - static ref COTD_45: f64 = - f64::cos(45.0 * radians_per_degree()) / f64::sin(45.0 * radians_per_degree()); - } - *COTD_45 -} - -fn asin_0_5() -> f64 { - lazy_static! { - static ref ASIN_0_5: f64 = f64::asin(0.5); - } - *ASIN_0_5 -} - -fn acos_0_5() -> f64 { - lazy_static! { - static ref ACOS_0_5: f64 = f64::acos(0.5); - } - *ACOS_0_5 -} - -fn radians_per_degree() -> f64 { - lazy_static! { - static ref RADIANS_PER_DEGREE: f64 = PI / 180.0; - } - *RADIANS_PER_DEGREE -} +static SIND_30: f64 = 0.499_999_999_999_999_94; +static ONE_MINUS_COSD_60: f64 = 0.499_999_999_999_999_9; +static TAND_45: f64 = 1.0; +static COTD_45: f64 = 1.0; +static ASIN_0_5: f64 = 0.523_598_775_598_298_8; +static ACOS_0_5: f64 = 1.047_197_551_196_597_6; // returns the cosine of an angle that lies between 0 and 60 degrees. This will return exactly 1 // when xi s 0, and exactly 0.5 when x is 60 degrees. fn cosd_0_to_60(x: f64) -> f64 { // https://github.com/postgres/postgres/blob/REL_15_2/src/backend/utils/adt/float.c - let one_minus_cos_x: f64 = 1.0 - f64::cos(x * radians_per_degree()); - 1.0 - (one_minus_cos_x / one_minus_cosd_60()) / 2.0 + let one_minus_cos_x: f64 = 1.0 - f64::cos(x * RADIANS_PER_DEGREE); + 1.0 - (one_minus_cos_x / ONE_MINUS_COSD_60) / 2.0 } // returns the sine of an angle that lies between 0 and 30 degrees. This will return exactly 0 when // x is 0, and exactly 0.5 when x is 30 degrees. fn sind_0_to_30(x: f64) -> f64 { // https://github.com/postgres/postgres/blob/REL_15_2/src/backend/utils/adt/float.c - let sin_x = f64::sin(x * radians_per_degree()); - (sin_x / sind_30()) / 2.0 + let sin_x = f64::sin(x * RADIANS_PER_DEGREE); + (sin_x / SIND_30) / 2.0 } // returns the cosine of an angle in the first quadrant (0 to 90 degrees). @@ -302,7 +259,7 @@ pub fn cotd_f64(input: F64) -> F64 { } let cot_arg1 = cosd_q1(arg1) / sind_q1(arg1); - let result = sign * (cot_arg1 / cotd_45()); + let result = sign * (cot_arg1 / COTD_45); // On some machines we get cotd(270) = minus zero, but this isn't always // true. For portability, and because the user constituency for this @@ -342,7 +299,7 @@ pub fn tand_f64(input: F64) -> F64 { } let tan_arg1 = sind_q1(arg1) / cosd_q1(arg1); - let result = sign * (tan_arg1 / tand_45()); + let result = sign * (tan_arg1 / TAND_45); // On some machines we get tand(180) = minus zero, but this isn't always true. For portability, // and because the user constituency for this function probably doesn't want minus zero, force @@ -361,11 +318,11 @@ pub fn asind_q1(x: f64) -> f64 { // monotonic functionover the full range. if x <= 0.5 { let asin_x = f64::asin(x); - return (asin_x / asin_0_5()) * 30.0; + return (asin_x / ASIN_0_5) * 30.0; } let acos_x = f64::acos(x); - 90.0 - (acos_x / acos_0_5()) * 60.0 + 90.0 - (acos_x / ACOS_0_5) * 60.0 } #[function("asind(float8) -> float8")] @@ -403,10 +360,10 @@ fn acosd_q1(x: f64) -> f64 { // monotonic function over the full range. if x <= 0.5 { let asin_x = f64::asin(x); - return 90.0 - (asin_x / asin_0_5()) * 30.0; + return 90.0 - (asin_x / ASIN_0_5) * 30.0; } let acos_x = f64::acos(x); - (acos_x / acos_0_5()) * 60.0 + (acos_x / ACOS_0_5) * 60.0 } #[function("acosd(float8) -> float8")]