2020-02-18 13:53:12 +00:00
|
|
|
#!/usr/bin/env bash
|
2020-02-14 19:48:45 +00:00
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-12-28 11:46:53 +00:00
|
|
|
# shellcheck source=../shell_config.sh
|
2020-08-01 00:51:12 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
2020-02-14 19:48:45 +00:00
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS regexp";
|
|
|
|
$CLICKHOUSE_CLIENT --query="CREATE TABLE regexp (id UInt32, array Array(UInt32), string String, date Date) ENGINE = Memory";
|
|
|
|
|
|
|
|
echo 'id: 1 array: [1,2,3] string: str1 date: 2020-01-01
|
|
|
|
id: 2 array: [1,2,3] string: str2 date: 2020-01-02
|
2022-04-03 07:52:44 +00:00
|
|
|
id: 3 array: [1,2,3] string: str3 date: 2020-01-03' | $CLICKHOUSE_CLIENT --query="INSERT INTO regexp SETTINGS format_regexp='id: (.+?) array: (.+?) string: (.+?) date: (.+?)', format_regexp_escaping_rule='Escaped' FORMAT Regexp ";
|
2020-02-14 19:48:45 +00:00
|
|
|
|
|
|
|
echo 'id: 4 array: "[1,2,3]" string: "str4" date: "2020-01-04"
|
|
|
|
id: 5 array: "[1,2,3]" string: "str5" date: "2020-01-05"
|
2022-04-03 07:52:44 +00:00
|
|
|
id: 6 array: "[1,2,3]" string: "str6" date: "2020-01-06"' | $CLICKHOUSE_CLIENT --query="INSERT INTO regexp SETTINGS format_regexp='id: (.+?) array: (.+?) string: (.+?) date: (.+?)', format_regexp_escaping_rule='CSV' FORMAT Regexp";
|
2020-02-14 19:48:45 +00:00
|
|
|
|
|
|
|
echo "id: 7 array: [1,2,3] string: 'str7' date: '2020-01-07'
|
|
|
|
id: 8 array: [1,2,3] string: 'str8' date: '2020-01-08'
|
2022-04-03 07:52:44 +00:00
|
|
|
id: 9 array: [1,2,3] string: 'str9' date: '2020-01-09'" | $CLICKHOUSE_CLIENT --query="INSERT INTO regexp SETTINGS format_regexp='id: (.+?) array: (.+?) string: (.+?) date: (.+?)', format_regexp_escaping_rule='Quoted' FORMAT Regexp";
|
2020-02-14 19:48:45 +00:00
|
|
|
|
|
|
|
echo 'id: 10 array: [1,2,3] string: "str10" date: "2020-01-10"
|
|
|
|
id: 11 array: [1,2,3] string: "str11" date: "2020-01-11"
|
2022-04-03 07:52:44 +00:00
|
|
|
id: 12 array: [1,2,3] string: "str12" date: "2020-01-12"' | $CLICKHOUSE_CLIENT --query="INSERT INTO regexp SETTINGS format_regexp='id: (.+?) array: (.+?) string: (.+?) date: (.+?)', format_regexp_escaping_rule='JSON' FORMAT Regexp";
|
2020-02-14 19:48:45 +00:00
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --query="SELECT * FROM regexp ORDER BY id";
|
|
|
|
$CLICKHOUSE_CLIENT --query="DROP TABLE regexp";
|
|
|
|
|