spaceandtimelabs / sxt-proof-of-sql

Space and Time | Proof of SQL
Other
2.75k stars 96 forks source link

feat: wood_types example #303

Closed henrymai closed 1 month ago

henrymai commented 1 month ago

Rationale for this change

Add an additional wood_types example to help improve documentation.

What changes are included in this PR?

wood_types example is added.

This patch includes a change to arrow_schema_utility::get_posql_compatible_schema to use a smaller precision and scale in order to allow for arithmetic on these columns (otherwise we will fail because we will overflow).

Are these changes tested?

Yes.

Parsing the query: SELECT COUNT(*) AS total_wood_types FROM woods...
Done in 0.32695100000000005 ms.
Generating proof...Done in 29.766170000000002 ms.
Verifying proof...Verified in 13.525808 ms.
Query Result:
Ok(OwnedTable { table: {Identifier { name: "total_wood_types" }: BigInt([10])} })
Parsing the query: SELECT common_use, SUM(density) as total_density, COUNT(*) as wood_count FROM woods GROUP BY common_use ORDER BY total_density DESC...
Done in 0.591261 ms.
Generating proof...Done in 66.24345299999999 ms.
Verifying proof...Verified in 29.65461 ms.
Query Result:
Ok(OwnedTable { table: {Identifier { name: "common_use" }: VarChar(["Piano keys", "Boat building", "Furniture", "Flooring", "Gunstocks", "Cabinetry", "Plywood", "Musical instruments", "Construction", "Outdoor furniture"]), Identifier { name: "total_density" }: Decimal75(Precision(20), 10, [MontScalar(BigInt([11000000000, 0, 0, 0])), MontScalar(BigInt([8000000000, 0, 0, 0])), MontScalar(BigInt([7500000000, 0, 0, 0])), MontScalar(BigInt([7000000000, 0, 0, 0])), MontScalar(BigInt([6800000000, 0, 0, 0])), MontScalar(BigInt([6500000000, 0, 0, 0])), MontScalar(BigInt([6200000000, 0, 0, 0])), MontScalar(BigInt([6000000000, 0, 0, 0])), MontScalar(BigInt([5500000000, 0, 0, 0])), MontScalar(BigInt([4500000000, 0, 0, 0]))]), Identifier { name: "wood_count" }: BigInt([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])} })
Parsing the query: SELECT common_use, COUNT(*) as c FROM woods GROUP BY common_use ORDER BY c DESC LIMIT 3...
Done in 0.498162 ms.
Generating proof...Done in 37.722410999999994 ms.
Verifying proof...Verified in 16.769167000000003 ms.
Query Result:
Ok(OwnedTable { table: {Identifier { name: "common_use" }: VarChar(["Boat building", "Cabinetry", "Construction"]), Identifier { name: "c" }: BigInt([1, 1, 1])} })
Parsing the query: SELECT name, hardness FROM woods WHERE density > 0.7 ORDER BY hardness DESC...
Done in 0.602504 ms.
Generating proof...Done in 77.030322 ms.
Verifying proof...Verified in 18.318061 ms.
Query Result:
Ok(OwnedTable { table: {Identifier { name: "name" }: VarChar(["Ebony", "Teak", "Oak"]), Identifier { name: "hardness" }: Decimal75(Precision(20), 10, [MontScalar(BigInt([90000000000, 0, 0, 0])), MontScalar(BigInt([75000000000, 0, 0, 0])), MontScalar(BigInt([70000000000, 0, 0, 0]))])} })
github-actions[bot] commented 1 month ago

:tada: This PR is included in version 0.33.10 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: