Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto-complete for field names and table names #509

Closed
Slach opened this issue Jan 17, 2024 · 0 comments · Fixed by #525
Closed

auto-complete for field names and table names #509

Slach opened this issue Jan 17, 2024 · 0 comments · Fixed by #525
Milestone

Comments

@Slach
Copy link
Collaborator

Slach commented Jan 17, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant