Summary
Autocomplete (also known as IntelliSense) is a familiar tool that developers use regularly. The problem it addresses is well-defined: providing relevant completion suggestions. In this article, we’ll share how we implement autocomplete in Bytebase.
Complexity of the tools used to check whether the cursor is within the SELECT clause is directly proportional to the scenarios they need to handle. In simpler cases, tools like regular expressions can suffice, but they may fail with more complex queries. In these cases, more advanced methods and tools are required.
Bytebase generates and maintains a parser for each SQL dialect based on ANTLR4. A non-scalable solution would quickly lead to an explosion of engineering effort.
In the example above, I use ellipses to represent grammar rules, while rounded rectangles represent terminals. If the input string is invalid, the parser will throw an error and will not proceed further.
Bytebase aims to provide accurate and effective SQL autocomplete functionality across different languages. The automaton-based approach is grounded in a universal mechanism that applies across languages.
The entire autocomplete architecture is actually very simple and consists of two parts. It uses the automaton and input to identify terminal symbols (keywords) and the grammar rules of interest. It primarily converts the candidate rules into corresponding strings and returns them to the user.
After the candidates, we need to find the ones that are most likely to be used in the next stage. The next step is to find out which of the following cases is most likely.
Once you have the table, you can use it to see the full length of the document. The full text of the article can be found at the bottom of the page.
In this week's edition of The Daily Discussion, we look at the role of technology in the world of business. This week's topic is the role played by technology in society.