123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- from ob_jobs.common import ChOptions
- def query_log_source_table(ch_opts: ChOptions):
- tmp_table_name = 't_query_log'
- sql = f"""
- create table {tmp_table_name} (
- `hostname` STRING,
- `type` STRING,
- `event_date` DATE,
- `event_time` TIMESTAMP,
- `query_start_time` TIMESTAMP,
- `query_duration_ms` DECIMAL,
- `read_rows` DECIMAL,
- `read_bytes` DECIMAL,
- `written_rows` DECIMAL,
- `written_bytes` DECIMAL,
- `result_rows` DECIMAL,
- `result_bytes` DECIMAL,
- `memory_usage` DECIMAL,
- `current_database` STRING,
- `query` STRING,
- `formatted_query` STRING,
- `normalized_query_hash` DECIMAL(20, 0),
- `query_kind` STRING,
- `databases` ARRAY<STRING>,
- `tables` ARRAY<STRING>,
- `columns` ARRAY<STRING>,
- `partitions` ARRAY<STRING>,
- `exception_code` INTEGER,
- `exception` STRING,
- `stack_trace` STRING,
- `is_initial_query` SMALLINT,
- `user` STRING,
- `query_id` STRING,
- `port` INTEGER,
- `client_name` STRING,
- `http_user_agent` STRING
- ) with (
- 'connector' = 'clickhouse',
- 'url' = 'clickhouse://{ch_opts.ch_host}:{ch_opts.ch_port}',
- 'database-name' = '{ch_opts.ch_dbname}',
- 'table-name' = 'query_log',
- 'username' = '{ch_opts.ch_user}',
- 'password' = '{ch_opts.ch_password}'
- )
- """
- return sql, tmp_table_name
|