datafuselabs / databend

š——š—®š˜š—®, š—”š—»š—®š—¹š˜†š˜š—¶š—°š˜€ & š—”š—œ. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.51k stars 717 forks source link

Allow query with optimizer disabled #7224

Open flaneur2020 opened 1 year ago

flaneur2020 commented 1 year ago

Summary

in the test suites of duckdb (https://duckdb.org/dev/testing) there's an important feature called query verification:

[Query Verification](https://duckdb.org/dev/testing#query-verification)
Many simple tests start by enabling query verification. This can be done through the following PRAGMA statement:

statement ok
PRAGMA enable_verification
Query verification performs extra validation to ensure that the underlying code runs correctly. The most important part of that is that it verifies that optimizers do not cause bugs in the query. It does this by running both an unoptimized and optimized version of the query, and verifying that the results of these queries are identical.

Query verification is very useful because it not only discovers bugs in optimizers, but also finds bugs in e.g. join implementations. This is because the unoptimized version will typically run using cross products instead. Because of this, query verification can be very slow to do when working with larger data sets. It is therefore recommended to turn on query verification for all unit tests, except those involving larger data sets (more than 10-100~ rows).

it allows one to query with optimizer disabled and compare the results between them, thus allows checking whether the optimizer works as expected: the result is not changed after optimizations.

if we want integrate the test suites from duckdb, this feature is a neccessary prelude.

flaneur2020 commented 1 year ago

cc @leiysky @ZeaLoVe

leiysky commented 1 year ago

It's possible to disable some of the optimizations.

I think we can skip the verification for now.

flaneur2020 commented 1 year ago

It's possible to disable some of the optimizations.

I think we can skip the verification for now.

+1, we can just verify the results at the client side.