risinglightdb / sqllogictest-rs

Sqllogictest parser and runner in Rust.
Apache License 2.0
167 stars 42 forks source link

feat: general variable substitution #196

Closed BugenZhao closed 9 months ago

BugenZhao commented 9 months ago

Support environment variables and special variables (like $__TEST_DIR__) substitution with the crate subst. Basically, this is a general form of the previous replace_keywords.

This is helpful if we want to don't want to hardcode some information in the SQL, for example, authentication information.

control substitution on

query T
select $MY_USERNAME, ${MY_PASSWORD}, ${MY_INEXISTENT_PORT:11451}, ${MY_DATABASE:$MY_USERNAME-db}
----
sqllogictest, rust, 11451, sqllogictest-db

query T
select $__TEST_DIR__
----
/var/folders/h3/ky82klmd2ygfr58ppqm4js6m0000gn/T/.tmp63ZLdk

See substitution/basic.slt for more detailed usages.

In order to be compatible with other implementations, this feature is under the gate of control substitution and is by default disabled.