Skip to content

Commit

Permalink
#31024: Using SQL script to init local ClickHouse (#31026)
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralfaro-dotcms authored Dec 30, 2024
1 parent 2b0345c commit f518903
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docker/docker-compose-examples/analytics/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ services:

ch_server:
container_name: ch_server
image: dotcms/clickhouse-server:latest
image: clickhouse/clickhouse-server:latest
ports:
- "${CH_HOST_PORT:-8124}:8123"
ulimits:
Expand All @@ -150,6 +150,7 @@ services:
- CLICKHOUSE_PASSWORD=${CH_PWD:-clickhouse_password}
volumes:
- ch_data:/var/lib/clickhouse
- ./setup/db/clickhouse/init-scripts:/docker-entrypoint-initdb.d

volumes:
workspace:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
CREATE DATABASE IF NOT EXISTS clickhouse_test_db;
CREATE TABLE IF NOT EXISTS clickhouse_test_db.events
(
_timestamp DateTime,
api_key String,
cluster_id String,
customer_id String,
doc_encoding String,
doc_host String,
doc_path String,
doc_search String,
event_type String,
eventn_ctx_event_id String,
ids_ajs_anonymous_id String,
local_tz_offset Int64,
page_title String,
parsed_ua_device_brand String,
parsed_ua_device_family String,
parsed_ua_device_model String,
parsed_ua_os_family String,
parsed_ua_os_version String,
parsed_ua_ua_family String,
parsed_ua_ua_version String,
referer String,
screen_resolution String,
source_ip String,
src String,
url String,
original_url String,
user_agent String,
user_anonymous_id String,
user_hashed_anonymous_id String,
userlanguage String,
user_language String,
utc_time DateTime,
vp_size String,
persona String,
ip String,
experiment String,
variant String,
lookbackwindow String,
language String,
runningid String,
isexperimentpage Bool,
istargetpage Bool,
ids_fbp String,
ids_ga String,
click_id_gclid String,
utm_campaign String,
utm_medium String,
utm_source String,
utm_term String,
utm_content String
) Engine = MergeTree()
PARTITION BY customer_id
ORDER BY (_timestamp, customer_id)
SETTINGS index_granularity = 8192;

ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_id String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_title String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_content_type_id String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_content_type_name String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_content_type_var_name String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_response String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_forward_to String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_detail_page_url String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS object_url String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS comefromvanityurl bool;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS request_id String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS host String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS sessionid String;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS sessionnew bool;
ALTER TABLE clickhouse_test_db.events ADD COLUMN IF NOT EXISTS rendermode String;

0 comments on commit f518903

Please sign in to comment.