2022-08-11 11:56:30 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
# shellcheck source=../shell_config.sh
|
|
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
|
2022-10-22 19:11:37 +00:00
|
|
|
model=$(mktemp "$CLICKHOUSE_TMP/obfuscator-model-XXXXXX.bin")
|
|
|
|
|
2022-09-05 12:46:26 +00:00
|
|
|
# Compared to explicitly specifying the structure of the input,
|
|
|
|
# schema inference adds Nullable(T) to all types, so the model and the results
|
|
|
|
# are a bit different from test '00175_obfuscator_schema_inference.sh'
|
|
|
|
|
2022-08-11 11:56:30 +00:00
|
|
|
$CLICKHOUSE_CLIENT --max_threads 1 --query="SELECT URL, Title, SearchPhrase FROM test.hits LIMIT 1000" > "${CLICKHOUSE_TMP}"/data.tsv
|
|
|
|
|
|
|
|
# Test obfuscator without saving the model
|
|
|
|
$CLICKHOUSE_OBFUSCATOR --input-format TSV --output-format TSV --seed hello --limit 2500 < "${CLICKHOUSE_TMP}"/data.tsv > "${CLICKHOUSE_TMP}"/data2500.tsv 2>/dev/null
|
|
|
|
|
|
|
|
# Test obfuscator with saving the model
|
2022-10-22 19:11:37 +00:00
|
|
|
$CLICKHOUSE_OBFUSCATOR --input-format TSV --output-format TSV --seed hello --limit 0 --save "$model" < "${CLICKHOUSE_TMP}"/data.tsv 2>/dev/null
|
|
|
|
wc -c < "$model"
|
|
|
|
$CLICKHOUSE_OBFUSCATOR --input-format TSV --output-format TSV --seed hello --limit 2500 --load "$model" < "${CLICKHOUSE_TMP}"/data.tsv > "${CLICKHOUSE_TMP}"/data2500_load_from_model.tsv 2>/dev/null
|
|
|
|
rm "$model"
|
2022-08-11 11:56:30 +00:00
|
|
|
|
|
|
|
$CLICKHOUSE_LOCAL --structure "URL String, Title String, SearchPhrase String" --input-format TSV --output-format TSV --query "SELECT count(), uniq(URL), uniq(Title), uniq(SearchPhrase) FROM table" < "${CLICKHOUSE_TMP}"/data.tsv
|
|
|
|
$CLICKHOUSE_LOCAL --structure "URL String, Title String, SearchPhrase String" --input-format TSV --output-format TSV --query "SELECT count(), uniq(URL), uniq(Title), uniq(SearchPhrase) FROM table" < "${CLICKHOUSE_TMP}"/data2500.tsv
|
|
|
|
$CLICKHOUSE_LOCAL --structure "URL String, Title String, SearchPhrase String" --input-format TSV --output-format TSV --query "SELECT count(), uniq(URL), uniq(Title), uniq(SearchPhrase) FROM table" < "${CLICKHOUSE_TMP}"/data2500_load_from_model.tsv
|
|
|
|
|
|
|
|
rm "${CLICKHOUSE_TMP}"/data.tsv
|
|
|
|
rm "${CLICKHOUSE_TMP}"/data2500.tsv
|
|
|
|
rm "${CLICKHOUSE_TMP}"/data2500_load_from_model.tsv
|