mike-lischke / antlr4-c3

A grammar agnostic code completion engine for ANTLR4 based parsers
MIT License
397 stars 62 forks source link

How to achieve sql column name auto completion? #65

Closed melin closed 2 years ago

melin commented 2 years ago

example: select na from tb1 a left join tb2 b a.code=b.code。 Enter na, how to get the table name: tb1 and tb2, more complex sql, may contain nesting, how to get the corresponding table name, query field information through the table name.

@mike-lischke

mike-lischke commented 2 years ago

This kind of information is something you have to collect. Usually you do some post processing of the input, with help of a symbol table containing possible tables, columns and so on. Check the implementation for MySQL in MySQL Workbench for a way to do that.