chdb-io / chdb

chDB is an in-process OLAP SQL Engine 🚀 powered by ClickHouse
https://clickhouse.com/chdb
Apache License 2.0
2.13k stars 75 forks source link

Is there a way to have system.query_log in chdb ? #261

Open LPauzies opened 2 months ago

LPauzies commented 2 months ago

I'm currently using chdb for our test suite. But as I use multiple 3rd party elements within the same test function, I would want to know what are the queries executed during each of my test functions.

To achieve this with a real ClickHouse, a call at the end of my function to system.query_log is sufficient for the current session. How can I have the same behavior using chdb ?

Here is the current tables inside system (show tables in system):

{
        "meta":
        [
                {
                        "name": "name",
                        "type": "String"
                }
        ],

        "data":
        [
                {
                        "name": "aggregate_function_combinators"
                },
                {
                        "name": "backups"
                },
                {
                        "name": "build_options"
                },
                {
                        "name": "collations"
                },
                {
                        "name": "columns"
                },
                {
                        "name": "contributors"
                },
                {
                        "name": "current_roles"
                },
                {
                        "name": "data_skipping_indices"
                },
                {
                        "name": "data_type_families"
                },
                {
                        "name": "databases"
                },
                {
                        "name": "dropped_tables"
                },
                {
                        "name": "enabled_roles"
                },
                {
                        "name": "errors"
                },
                {
                        "name": "events"
                },
                {
                        "name": "formats"
                },
                {
                        "name": "functions"
                },
                {
                        "name": "grants"
                },
                {
                        "name": "kafka_consumers"
                },
                {
                        "name": "licenses"
                },
                {
                        "name": "merge_tree_settings"
                },
                {
                        "name": "numbers"
                },
                {
                        "name": "numbers_mt"
                },
                {
                        "name": "one"
                },
                {
                        "name": "privileges"
                },
                {
                        "name": "quota_limits"
                },
                {
                        "name": "quota_usage"
                },
                {
                        "name": "quotas"
                },
                {
                        "name": "quotas_usage"
                },
                {
                        "name": "replicated_merge_tree_settings"
                },
                {
                        "name": "rocksdb"
                },
                {
                        "name": "role_grants"
                },
                {
                        "name": "roles"
                },
                {
                        "name": "row_policies"
                },
                {
                        "name": "scheduler"
                },
                {
                        "name": "schema_inference_cache"
                },
                {
                        "name": "server_settings"
                },
                {
                        "name": "settings"
                },
                {
                        "name": "settings_changes"
                },
                {
                        "name": "settings_profile_elements"
                },
                {
                        "name": "settings_profiles"
                },
                {
                        "name": "stack_trace"
                },
                {
                        "name": "table_engines"
                },
                {
                        "name": "table_functions"
                },
                {
                        "name": "tables"
                },
                {
                        "name": "time_zones"
                },
                {
                        "name": "user_directories"
                },
                {
                        "name": "users"
                },
                {
                        "name": "warnings"
                },
                {
                        "name": "zeros"
                },
                {
                        "name": "zeros_mt"
                }
        ],

        "rows": 50,

        "statistics":
        {
                "elapsed": 0.00140087,
                "rows_read": 0,
                "bytes_read": 0
        }
}

Thanks :pray: