diff --git a/coverage/translation-databricks/obligations/functions.toml b/coverage/translation-databricks/obligations/functions.toml index 5dfdb81e6..8703e609b 100644 --- a/coverage/translation-databricks/obligations/functions.toml +++ b/coverage/translation-databricks/obligations/functions.toml @@ -6043,6 +6043,39 @@ reading = "the argument types the generator read from the function's page" cases = ["cases/translation/functions/convert-timezone.toml#t010_wrong_kind"] required = true +[[obligation]] +id = "db.functions.corr.t008" +form = "db.functions.corr" +kind = "type_combination" +target = "DOUBLE, DOUBLE" +note = "corr where the first argument never varies. Expected NULL, from Spark's Corr: its result is NULL when either accumulated second moment is exactly zero, where the coefficient's formula divides by zero. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/corr.constant.hand.toml#c001"] +required = true + +[[obligation]] +id = "db.functions.corr.t009" +form = "db.functions.corr" +kind = "type_combination" +target = "INT, INT" +note = "corr where the second argument never varies. Expected NULL, from Spark's Corr: the same zero-moment branch, on the other argument. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/corr.constant.hand.toml#c002"] +required = true + +[[obligation]] +id = "db.functions.corr.t010" +form = "db.functions.corr" +kind = "type_combination" +target = "INT, INT" +note = "corr of a single pair. Expected NULL, from Spark's Corr: a count of one returns its divide-by-zero result, NULL unless spark.sql.legacy.statisticalAggregate is set. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/corr.constant.hand.toml#c003"] +required = true + [[obligation]] id = "db.functions.corr.t001" form = "db.functions.corr" @@ -18033,6 +18066,28 @@ reading = "the argument types the generator read from the function's page" cases = ["cases/translation/functions/kll-sketch-to-string-float.toml#t004_wrong_kind"] required = true +[[obligation]] +id = "db.functions.kurtosis.t006" +form = "db.functions.kurtosis" +kind = "type_combination" +target = "DOUBLE" +note = "kurtosis of a value that never varies. Expected NULL, from Spark's Kurtosis: a second central moment of exactly zero returns its divide-by-zero result, NULL unless spark.sql.legacy.statisticalAggregate is set. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/kurtosis.constant.hand.toml#c001"] +required = true + +[[obligation]] +id = "db.functions.kurtosis.t007" +form = "db.functions.kurtosis" +kind = "type_combination" +target = "INT" +note = "kurtosis of a single value. Expected NULL, from Spark's Kurtosis: one value leaves the second central moment at zero, the same branch. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/kurtosis.constant.hand.toml#c002"] +required = true + [[obligation]] id = "db.functions.kurtosis.t001" form = "db.functions.kurtosis" @@ -26140,6 +26195,28 @@ reading = "the argument types the generator read from the function's page" cases = ["cases/translation/functions/regr-count.toml#t011_wrong_kind"] required = true +[[obligation]] +id = "db.functions.regr-intercept.t008" +form = "db.functions.regr-intercept" +kind = "type_combination" +target = "DOUBLE, DOUBLE" +note = "regr_intercept where x never varies. Expected NULL, from Spark's RegrIntercept: a population variance of x of exactly zero returns NULL, where the formula divides by zero. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/regr-intercept.constant.hand.toml#c001"] +required = true + +[[obligation]] +id = "db.functions.regr-intercept.t009" +form = "db.functions.regr-intercept" +kind = "type_combination" +target = "DOUBLE, DOUBLE" +note = "regr_intercept where y never varies and x does. Expected 2.5, from the formula: the intercept is the mean of y less a zero slope times the mean of x. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/regr-intercept.constant.hand.toml#c002"] +required = true + [[obligation]] id = "db.functions.regr-intercept.t001" form = "db.functions.regr-intercept" @@ -26217,6 +26294,28 @@ reading = "the argument types the generator read from the function's page" cases = ["cases/translation/functions/regr-intercept.toml#t011_wrong_kind"] required = true +[[obligation]] +id = "db.functions.regr-r2.t008" +form = "db.functions.regr-r2" +kind = "type_combination" +target = "DOUBLE, DOUBLE" +note = "regr_r2 where y never varies and x does. Expected 1.0, from Spark's RegrR2: with the dependent variable's second moment zero and the independent one's not, it returns 1.0. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/regr-r2.constant.hand.toml#c001"] +required = true + +[[obligation]] +id = "db.functions.regr-r2.t009" +form = "db.functions.regr-r2" +kind = "type_combination" +target = "DOUBLE, DOUBLE" +note = "regr_r2 where x never varies. Expected NULL, from Spark's RegrR2: with the independent variable's second moment zero it returns NULL. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/regr-r2.constant.hand.toml#c002"] +required = true + [[obligation]] id = "db.functions.regr-r2.t001" form = "db.functions.regr-r2" @@ -26294,6 +26393,28 @@ reading = "the argument types the generator read from the function's page" cases = ["cases/translation/functions/regr-r2.toml#t011_wrong_kind"] required = true +[[obligation]] +id = "db.functions.regr-slope.t008" +form = "db.functions.regr-slope" +kind = "type_combination" +target = "DOUBLE, DOUBLE" +note = "regr_slope where x never varies. Expected NULL, from Spark's RegrSlope: a population variance of x of exactly zero returns NULL, where the formula divides by zero. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/regr-slope.constant.hand.toml#c001"] +required = true + +[[obligation]] +id = "db.functions.regr-slope.t009" +form = "db.functions.regr-slope" +kind = "type_combination" +target = "DOUBLE, DOUBLE" +note = "regr_slope where y never varies and x does. Expected 0.0, from the formula: the co-moment of x with a constant y is zero, so the slope is zero over x's nonzero second moment. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/regr-slope.constant.hand.toml#c002"] +required = true + [[obligation]] id = "db.functions.regr-slope.t001" form = "db.functions.regr-slope" @@ -28670,6 +28791,28 @@ reading = "the argument types the generator read from the function's page" cases = ["cases/translation/functions/size.toml#t007_wrong_kind"] required = true +[[obligation]] +id = "db.functions.skewness.t006" +form = "db.functions.skewness" +kind = "type_combination" +target = "DOUBLE" +note = "skewness of a value that never varies. Expected NULL, from Spark's Skewness: a second central moment of exactly zero returns its divide-by-zero result, NULL unless spark.sql.legacy.statisticalAggregate is set. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/skewness.constant.hand.toml#c001"] +required = true + +[[obligation]] +id = "db.functions.skewness.t007" +form = "db.functions.skewness" +kind = "type_combination" +target = "INT" +note = "skewness of a single value. Expected NULL, from Spark's Skewness: one value leaves the second central moment at zero, the same branch. Hand-written." +catches = "the argument types read another way, or the result typed otherwise" +reading = "the argument types the generator read from the function's page" +cases = ["cases/translation/functions/skewness.constant.hand.toml#c002"] +required = true + [[obligation]] id = "db.functions.skewness.t001" form = "db.functions.skewness" diff --git a/coverage/translation-databricks/results-baseline.json b/coverage/translation-databricks/results-baseline.json index 1a817fc33..b4640b926 100644 --- a/coverage/translation-databricks/results-baseline.json +++ b/coverage/translation-databricks/results-baseline.json @@ -986,6 +986,9 @@ "translation/functions/convert-timezone.toml#t008_boundary_3": "matching_error", "translation/functions/convert-timezone.toml#t009_boundary_4": "matching_error", "translation/functions/convert-timezone.toml#t010_wrong_kind": "matching_error", + "translation/functions/corr.constant.hand.toml#c001": "matching", + "translation/functions/corr.constant.hand.toml#c002": "matching", + "translation/functions/corr.constant.hand.toml#c003": "matching", "translation/functions/corr.toml#t001_types_1": "matching", "translation/functions/corr.toml#t002_types_2": "matching", "translation/functions/corr.toml#t003_types_3": "matching", @@ -2606,6 +2609,8 @@ "translation/functions/kll-sketch-to-string-float.toml#t002_null_1": "refused", "translation/functions/kll-sketch-to-string-float.toml#t003_boundary_1": "refused", "translation/functions/kll-sketch-to-string-float.toml#t004_wrong_kind": "refused", + "translation/functions/kurtosis.constant.hand.toml#c001": "matching", + "translation/functions/kurtosis.constant.hand.toml#c002": "matching", "translation/functions/kurtosis.toml#t001_types_1": "matching", "translation/functions/kurtosis.toml#t002_types_2": "matching", "translation/functions/kurtosis.toml#t003_types_3": "matching", @@ -3680,6 +3685,8 @@ "translation/functions/regr-count.toml#t009_boundary_3": "matching", "translation/functions/regr-count.toml#t010_boundary_4": "matching", "translation/functions/regr-count.toml#t011_wrong_kind": "matching_error", + "translation/functions/regr-intercept.constant.hand.toml#c001": "matching", + "translation/functions/regr-intercept.constant.hand.toml#c002": "matching", "translation/functions/regr-intercept.toml#t001_types_1": "matching", "translation/functions/regr-intercept.toml#t002_types_2": "matching", "translation/functions/regr-intercept.toml#t003_types_3": "matching", @@ -3691,6 +3698,8 @@ "translation/functions/regr-intercept.toml#t009_boundary_3": "matching", "translation/functions/regr-intercept.toml#t010_boundary_4": "matching", "translation/functions/regr-intercept.toml#t011_wrong_kind": "matching_error", + "translation/functions/regr-r2.constant.hand.toml#c001": "matching", + "translation/functions/regr-r2.constant.hand.toml#c002": "matching", "translation/functions/regr-r2.toml#t001_types_1": "matching", "translation/functions/regr-r2.toml#t002_types_2": "matching", "translation/functions/regr-r2.toml#t003_types_3": "matching", @@ -3702,6 +3711,8 @@ "translation/functions/regr-r2.toml#t009_boundary_3": "matching", "translation/functions/regr-r2.toml#t010_boundary_4": "matching", "translation/functions/regr-r2.toml#t011_wrong_kind": "matching_error", + "translation/functions/regr-slope.constant.hand.toml#c001": "matching", + "translation/functions/regr-slope.constant.hand.toml#c002": "matching", "translation/functions/regr-slope.toml#t001_types_1": "matching", "translation/functions/regr-slope.toml#t002_types_2": "matching", "translation/functions/regr-slope.toml#t003_types_3": "matching", @@ -4018,6 +4029,8 @@ "translation/functions/size.toml#t005_boundary_1": "matching", "translation/functions/size.toml#t006_boundary_2": "matching", "translation/functions/size.toml#t007_wrong_kind": "matching_rejection", + "translation/functions/skewness.constant.hand.toml#c001": "matching", + "translation/functions/skewness.constant.hand.toml#c002": "matching", "translation/functions/skewness.toml#t001_types_1": "matching", "translation/functions/skewness.toml#t002_types_2": "matching", "translation/functions/skewness.toml#t003_types_3": "matching", @@ -8568,6 +8581,9 @@ "db.functions.corr.t005": "met", "db.functions.corr.t006": "met", "db.functions.corr.t007": "met", + "db.functions.corr.t008": "met", + "db.functions.corr.t009": "met", + "db.functions.corr.t010": "met", "db.functions.cos.t001": "met", "db.functions.cos.t002": "met", "db.functions.cos.t003": "met", @@ -9656,6 +9672,8 @@ "db.functions.kurtosis.t003": "met", "db.functions.kurtosis.t004": "met", "db.functions.kurtosis.t005": "met", + "db.functions.kurtosis.t006": "met", + "db.functions.kurtosis.t007": "met", "db.functions.lag.t001": "met", "db.functions.lag.t002": "met", "db.functions.lag.t003": "met", @@ -10395,6 +10413,8 @@ "db.functions.regr-intercept.t005": "met", "db.functions.regr-intercept.t006": "met", "db.functions.regr-intercept.t007": "met", + "db.functions.regr-intercept.t008": "met", + "db.functions.regr-intercept.t009": "met", "db.functions.regr-r2.t001": "met", "db.functions.regr-r2.t002": "met", "db.functions.regr-r2.t003": "met", @@ -10402,6 +10422,8 @@ "db.functions.regr-r2.t005": "met", "db.functions.regr-r2.t006": "met", "db.functions.regr-r2.t007": "met", + "db.functions.regr-r2.t008": "met", + "db.functions.regr-r2.t009": "met", "db.functions.regr-slope.t001": "met", "db.functions.regr-slope.t002": "met", "db.functions.regr-slope.t003": "met", @@ -10409,6 +10431,8 @@ "db.functions.regr-slope.t005": "met", "db.functions.regr-slope.t006": "met", "db.functions.regr-slope.t007": "met", + "db.functions.regr-slope.t008": "met", + "db.functions.regr-slope.t009": "met", "db.functions.regr-sxx.t001": "met", "db.functions.regr-sxx.t002": "met", "db.functions.regr-sxx.t003": "met", @@ -10623,6 +10647,8 @@ "db.functions.skewness.t003": "met", "db.functions.skewness.t004": "met", "db.functions.skewness.t005": "met", + "db.functions.skewness.t006": "met", + "db.functions.skewness.t007": "met", "db.functions.slashsign.t001": "met", "db.functions.slashsign.t002": "met", "db.functions.slashsign.t003": "met", diff --git a/crates/sqlbabel-policy/policy-databricks.toml b/crates/sqlbabel-policy/policy-databricks.toml index e56dc00b8..dd52d7649 100644 --- a/crates/sqlbabel-policy/policy-databricks.toml +++ b/crates/sqlbabel-policy/policy-databricks.toml @@ -371,7 +371,7 @@ constructs = ["fn:VAR_POP", "fn:SKEWNESS", "fn:KURTOSIS", "fn:COVAR_POP", "fn:CO replay = "warn" default = "allow" failure = "value" -reason = "VAR_POP, SKEWNESS, KURTOSIS, COVAR_POP, COVAR_SAMP, CORR and the REGR_ statistics other than REGR_COUNT, REGR_AVGX and REGR_AVGY update a running count, means and central moments or co-moments row by row in DOUBLE, as Spark's CentralMomentAgg, Covariance and PearsonCorrelation do. The converted SQL repeats that arithmetic exactly in the order DuckDB collects the rows, so its result is one Databricks itself returns for some order of the same rows: within Databricks's own row-order variation, which reaches the last digits, and further where the values share a large mean and vary little." +reason = "VAR_POP, SKEWNESS, KURTOSIS, COVAR_POP, COVAR_SAMP, CORR and the REGR_ statistics other than REGR_COUNT, REGR_AVGX and REGR_AVGY update a running count, means and central moments or co-moments row by row in DOUBLE, as Spark's CentralMomentAgg, Covariance and PearsonCorrelation do. The converted SQL repeats that arithmetic exactly in the order DuckDB collects the rows, so its result is one Databricks itself returns for some order of the same rows. Databricks's own result varies with that order and also with how the rows are split into partitions, whose partial counts, means and moments Spark merges in no fixed order. The variation reaches the last digits, and goes further where the values share a large mean and vary little." # VAR_SAMP, STDDEV_SAMP, STDDEV_POP and their aliases VARIANCE, STDDEV and STD: the converted SQL # computes them in two passes over the rows DuckDB collects, the mean, then the sum of squared diff --git a/evidence.toml b/evidence.toml index 5a24bec45..3a8f9fe69 100644 --- a/evidence.toml +++ b/evidence.toml @@ -12,8 +12,8 @@ commit = "8fa4e1c4bbb26244cc79db482ce162ed6d425826" content_sha256 = "8525473a489f5b41e5d8690c333668a743c811bb9bd5666d454cf50fc6b4943e" [pins.databricks] -commit = "25a15649341992dee2bf4fc5869da19d2719e4cd" -content_sha256 = "3317ff754b559991432a0be8c8f6ae7190d7ce26b5a29b0c83514dd69b36ae67" +commit = "587e0f42c106615891b2dcc1e9dc4de9abe756fd" +content_sha256 = "e97013645ff397e5f575cc248baa6e64c5e4e59d2783c7ae8b129c71f0cd53d0" [pins.duckdb] commit = "fa4ccd4dc55cb2d1fb2d37236c35b8b755045001"