databendlabs / databend

𝗗𝗮𝘁𝗮, 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 & 𝗔𝗜. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.85k stars 750 forks source link

feature: Settings clause #16387

Closed sundy-li closed 2 weeks ago

sundy-li commented 2 months ago

Summary

syntax

SETTINGS ( parameter = value [ , parameter = value ] )  Statement

SETTINGS clause works only in Statement of:

SELECT
INSERT 
MergeINTO
COPY
UPDATE
DELETE
CREATE TABLE 
EXPLAIN

examples:

settings (max_thread = 3,  enable_loser_tree_merge_sort = 1) select  1 + 1 
settings (max_thread = 3,  enable_loser_tree_merge_sort = 1)  copy into ....

We already had set_var_hints now, but the syntax is not friendly. Settings could also be parsed into HintItem.

Any advice? cc @zhang2014 @andylokandy

Refer to https://docs.yellowbrick.com/6.8.1/ybd_sqlref/setting_clause.html

BohuTANG commented 2 months ago

Why not use set_var to do it?

zhang2014 commented 2 months ago

LGTM

TCeason commented 1 month ago

Maybe add a new type in SetType is better than HintItem?

pub enum SetType {
    #[default]
    SettingsSession,
    SettingsGlobal,
    Variable,
    SettingsQuery,
}

And if user use query level settings and hints , the hints will be invalid.

That's easy to delete the code about hints.