Commit 263aa0c
authored
feat: general variable substitution (#196)
Support environment variables and special variables (like `$__TEST_DIR__`) substitution with the crate [`subst`](crates.io/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.1 parent d554415 commit 263aa0c
File tree
18 files changed
+538
-304
lines changed- sqllogictest-bin
- sqllogictest-engines
- sqllogictest
- src
- tests
- substitution
- system_command
- test_dir_escape
18 files changed
+538
-304
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
10 | 44 | | |
11 | 45 | | |
12 | 46 | | |
| |||
0 commit comments