for dynamic autocomplete highlight as identifier color
Need to execute two queries during SQLEditor initialization
better have some global state to avoid multiple parallel the same queries
first for detect system tables
SELECT name FROM system.tables
WHERE database='system' AND name IN (
'functions','table_engines','formats',
'table_functions','data_type_families','merge_tree_settings',
'settings','clusters','macros','storage_policies','aggregate_function_combinators',
'database','tables','dictionaries','columns'
)
second for create autocompletion list
this is the full query we shall skip UNION ALL for tables
SELECT DISTINCT arrayJoin(extractAll(name, '[\\w_]{2,}')) AS completion, color
FROM (
SELECT name, 'identifier' AS color FROM system.functions
UNION ALL
SELECT name, 'keyword' AS color FROM system.table_engines
UNION ALL
SELECT name, 'keyword' AS color FROM system.formats
UNION ALL
SELECT name, 'identifier' AS color FROM system.table_functions
UNION ALL
SELECT name, 'identifier' AS color FROM system.data_type_families
UNION ALL
SELECT name. 'identifier' AS color FROM system.merge_tree_settings
UNION ALL
SELECT name, 'identifier' AS color FROM system.settings
UNION ALL
SELECT cluster,'string' AS color FROM system.clusters
UNION ALL
SELECT macro,'string' AS color FROM system.macros
UNION ALL
SELECT policy_name, 'string' AS color FROM system.storage_policies
UNION ALL
SELECT concat(func.name, comb.name), 'identifier' AS color FROM system.functions AS func CROSS JOIN system.aggregate_function_combinators AS comb WHERE is_aggregate
UNION ALL
SELECT name, 'identifier' AS color FROM system.databases LIMIT 10000
UNION ALL
SELECT DISTINCT name, 'identifier' AS color FROM system.tables LIMIT 10000
UNION ALL
SELECT DISTINCT name, 'identifier' AS color FROM system.dictionaries LIMIT 10000
UNION ALL
SELECT DISTINCT name, 'identifier' AS color FROM system.columns LIMIT 10000
) WHERE notEmpty(completion)
executing query one time during initialization SQLEditor inside QueryEditor panel
multiple panel should execute only One SQL queries if possible
for dynamic autocomplete highlight as
identifier
colorNeed to execute two queries during SQLEditor initialization better have some global state to avoid multiple parallel the same queries
first for detect system tables
second for create autocompletion list this is the full query we shall skip UNION ALL for tables
executing query one time during initialization SQLEditor inside QueryEditor panel multiple panel should execute only One SQL queries if possible