set allow_experimental_object_type = 1;
CREATE TABLE  IF NOT EXISTS nudgebee.dw_queries_shard on cluster 'default'(
	id String,
	tenant_id String,
	account_id String,
	resource_id String,
	tags String DEFAULT '{}',
	database_name String,
	db_username String,
	query_type String,
	query_exec_duration_micro UInt64,
	bill_total_duration_micro UInt64,
	bill_interval_from Datetime,
	bill_interval_to Datetime,
	created_at Datetime,
	bill Float64,
	rpu Float64,
	query_text String,
	query_planning_duration_micro UInt64,
	query_error_message String,
	query_returned_rows UInt64,
	query_returned_bytes UInt64,
	query_usage_limit String,
	query_transaction_id String,
	query_session_id String,
	query_status String,
	query_result_cache_hit Bool,
	query_started_at Datetime,
	query_ended_at Datetime,
	query_id String,
	query_queue_duration_micro UInt64,
	query_normalized String,
	query_normalized_md5 String,
	queue_provision_time Float64,
	queue_repair_time Float64,
	queue_overload_time Float64,
	partitions_scanned Float64,
	bytes_scanned Float64,
	bytes_spilled_locally Float64,
	bytes_spilled_remotely Float64,
	transaction_block_time Float64,
	table_names Array(String),
	query_remote_ip String,
	query_md5 String
)
ENGINE = ReplacingMergeTree
ORDER BY(tenant_id, account_id, resource_id, query_id, database_name, db_username, query_md5)
PARTITION BY toYYYYMM(query_started_at);