Skip to content

Read Primitives — Decimal Arithmetic

Read Primitives benchmark · all Read Primitives queries

Decimal precision arithmetic with complex expressions

Representative SQL

Rendered for DataFusion with default parameters.

SELECT
l_orderkey,
l_extendedprice * (
1 - l_discount
) * (
1 + l_tax
) AS final_price,
l_extendedprice / l_quantity AS unit_price
FROM lineitem
WHERE
l_quantity > 0
LIMIT 1000

Representative DataFrame

Expression family (Polars, PySpark, DataFusion), default parameters.

def decimal_arithmetic_expression_impl(ctx: DataFrameContext) -> Any:
col, lit = ctx.col, ctx.lit
return (
ctx.get_table("lineitem")
.filter(col("l_quantity") > lit(0))
.select(
col("l_orderkey"),
(col("l_extendedprice") * (lit(1) - col("l_discount")) * (lit(1) + col("l_tax"))).alias("final_price"),
(col("l_extendedprice") / col("l_quantity")).alias("unit_price"),
)
.limit(1000)
)

Get the exact query for your run

The blocks above are representative. To get the precise statement a specific platform runs at a specific scale, substitute your own values:

from benchbox import ReadPrimitives
bench = ReadPrimitives(scale_factor=0.01) # your scale factor
queries = bench.get_queries(dialect="datafusion") # your platform's dialect; drop dialect= for native SQL
print(queries['decimal_arithmetic'])

For the DataFrame form:

from benchbox.core.query_catalog import get_dataframe_render
print(get_dataframe_render('read_primitives', 'decimal_arithmetic', family="expression").source) # or family="pandas"

Source

Query text: benchbox/core/read_primitives/queries.py