coderfender commented on code in PR #20593: URL: https://github.com/apache/datafusion/pull/20593#discussion_r2913829157
########## datafusion/sqllogictest/test_files/spark/math/ceil.slt: ########## @@ -21,22 +21,138 @@ # For more information, please see: # https://github.com/apache/datafusion/issues/15914 +# Tests for Spark-compatible ceil function. +# Spark semantics differ from DataFusion's built-in ceil in two ways: +# 1. Return type: Spark returns Int64 for float/integer inputs; +# DataFusion returns the same float type (e.g. ceil(1.5::DOUBLE) -> DOUBLE in DF, BIGINT in Spark) +# 2. Decimal precision: Spark adjusts precision to (p - s + 1) for Decimal128(p, s) with scale > 0; +# DataFusion preserves the original precision and scale +# +# Example: SELECT ceil(1.50::DECIMAL(10,2)) +# Spark: returns Decimal(9, 0) value 2 +# DataFusion: returns Decimal(10, 2) value 2.00 + ## Original Query: SELECT ceil(-0.1); ## PySpark 3.5.5 Result: {'CEIL(-0.1)': Decimal('0'), 'typeof(CEIL(-0.1))': 'decimal(1,0)', 'typeof(-0.1)': 'decimal(1,1)'} -#query -#SELECT ceil(-0.1::decimal(1,1)); +query R +SELECT ceil(-0.1::decimal(1,1)); +---- +0 ## Original Query: SELECT ceil(3.1411, -3); ## PySpark 3.5.5 Result: {'ceil(3.1411, -3)': Decimal('1000'), 'typeof(ceil(3.1411, -3))': 'decimal(4,0)', 'typeof(3.1411)': 'decimal(5,4)', 'typeof(-3)': 'int'} +## TODO: 2-argument ceil(value, scale) is not yet implemented #query #SELECT ceil(3.1411::decimal(5,4), -3::int); ## Original Query: SELECT ceil(3.1411, 3); ## PySpark 3.5.5 Result: {'ceil(3.1411, 3)': Decimal('3.142'), 'typeof(ceil(3.1411, 3))': 'decimal(5,3)', 'typeof(3.1411)': 'decimal(5,4)', 'typeof(3)': 'int'} +## TODO: 2-argument ceil(value, scale) is not yet implemented Review Comment: I would put it this comment in the rust file as well :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
