<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ydb/yql/essentials/sql/v1/complete/sql_complete.h, branch CLI_2.21.0</title>
<subtitle>Mirror of YDB github repos</subtitle>
<id>https://code.mastervirt.ru/ydb/atom?h=CLI_2.21.0</id>
<link rel='self' href='https://code.mastervirt.ru/ydb/atom?h=CLI_2.21.0'/>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/'/>
<updated>2025-05-06T13:04:08Z</updated>
<entry>
<title>YQL-19747 Complete folder, table and cluster names</title>
<updated>2025-05-06T13:04:08Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-05-06T12:49:02Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=9c3fdca51d8ae892c5ad8f6ef92df73fafc09e28'/>
<id>urn:sha1:9c3fdca51d8ae892c5ad8f6ef92df73fafc09e28</id>
<content type='text'>
---

- Related to `YQL-19747`
- On top of https://github.com/ytsaurus/ytsaurus/pull/1253
- Related to https://github.com/ydb-platform/ydb/issues/9056
- Related to https://github.com/vityaman/ydb/issues/14
- Related to https://github.com/vityaman/ydb/issues/35
- Related to https://github.com/vityaman/ydb/issues/40

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1257
commit_hash:0b842abb27184c88b8177beeea29fb1ea86b7a04
</content>
</entry>
<entry>
<title>YQL-19747: Refactor sql/v1/complete usage of Future and Ptr</title>
<updated>2025-04-25T13:30:34Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-04-25T13:08:47Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=2b59203eb9ccded916b53b3410e3f15abf4b623f'/>
<id>urn:sha1:2b59203eb9ccded916b53b3410e3f15abf4b623f</id>
<content type='text'>
- [x] Chained futures, add `CompleteAsync` method (then will migrate the YDB CLI on it).
- [x] Removed deadlined and fallback NameService as unused
- [x] Annotate thread-safe methods with `const` and use `AtomicSharedPtr` for them.
- [x] Move `name` to `name/service` with backward compatibility with the YDB CLI.

---

`CompletionEngine` is left thread-unsafe because of the dependency chain `CompletionEngine -&gt; LocalSyntaxAnalysis -&gt; C3Engine` which is thread-unsafe, but readonly indexed data structures such as `Ranking` and `NameService` are annotated with const and distributed via shared pointers.

I removed deadlined and fallback name services because the first is stupid the second is ahead of its time and is better to be added later to keep interfaces as minimal as possible.

---

The migration on async complete plan:
1. Introduce CompleteAsync
2. Migrate clients on CompleteAsync
3. Make Complete to return Future
4. Migrate clients on Complete
5. Remove CompleteAsync

---

- Related to https://github.com/ydb-platform/ydb/issues/9056
- Related to https://github.com/vityaman/ydb/issues/33
- Related to https://github.com/vityaman/ydb/issues/31

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1241

Co-authored-by: vvvv &lt;vvvv@yandex-team.com&gt;
Co-authored-by: vvvv &lt;vvvv@yandex-team.com&gt;
commit_hash:497cc081ab78bebf7354e0acfaa418d936cc8240
</content>
</entry>
<entry>
<title>YQL-19747 Detect a token at the caret position</title>
<updated>2025-04-23T12:27:38Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-04-23T12:04:48Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=c222f6f103376934dd705e16bf9a3bad66e44365'/>
<id>urn:sha1:c222f6f103376934dd705e16bf9a3bad66e44365</id>
<content type='text'>
When I tried to implement a folder and object names completion at `ID_QUOTED` I faced with a problem, that I actually can't detect, that cursor is at `ID_QUOTED` token because `TCompletionInput::Text` it was cut until the `TCompletionInput::CursorPosition`, therefore at input ``` SELECT * FROM `#` ``` prefix was ``` SELECT * FROM `# ``` and then lexer failed.

While we actually want tokenize the whole current statement, `C3` still needs to receive a prefix as input. I tried to tokenize the whole statement and then on input `SELECT Optional&lt;#&gt;` got nothing because `&lt;&gt;` is solid token in the `SQL`. The only way to fix it I found is to cut a query to prefix until the cursor position.

BTW, current implementation is not so efficient as we tokenize the input multiple times. Especially `SplitQueryToStatemnts` seems heavy. In future we anyway will parse the whole input so will need to design APIs to receive ready token streams to do statements splitting, for example, just not to do the work twice.

![image](https://github.com/user-attachments/assets/114804d3-f311-4a46-be84-8ed4650bc9dd)

So I introduce you the following changes

- [x] Select the whole current statement, not just prefix.
- [x] Find the token at caret and output no candidates when caret is at `STRING_VALUE`, `DIGIGTS` and so on.
- [x] Change `C3` wrapper interface to take `TCompletionInput` to hide an implementation detail that it runs on cut prefix.
- [x] `#` annotated queries in unit tests.
- [x] Detect `CaretTokenPosition` -- if is it enclosed with a token or between two.
- [x] Ensure that `maxErrors` in `ILexer::Tokenize` is positive. Just a tiny bugfix.

---

- Related to https://github.com/ytsaurus/ytsaurus/pull/1209
- Related to https://github.com/ydb-platform/ydb/issues/9056
- Related to https://github.com/vityaman/ydb/issues/14

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1225
commit_hash:a434b9888ec8a7356247d63d9f1420e256ae4fca
</content>
</entry>
<entry>
<title>YQL-19747 Remove default completion engine factory</title>
<updated>2025-04-15T11:57:48Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-04-15T11:30:08Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=c3eed92629687af94073f570c29ea338bdd66548'/>
<id>urn:sha1:c3eed92629687af94073f570c29ea338bdd66548</id>
<content type='text'>
This is to decouple from the `sql/v1/lexer` implementation.

- Related to https://github.com/ydb-platform/ydb/issues/9056
- Related to https://github.com/vityaman/ydb/issues/18
- Following https://github.com/ydb-platform/ydb/pull/16820

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1196
commit_hash:4995f3a7cb14b0b735a48e211111764f65be8033
</content>
</entry>
<entry>
<title>YQL-19747 Complete select and insert hints</title>
<updated>2025-04-09T15:12:05Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-04-09T14:57:35Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=394fee4aa8d48e58cf82c72bcb9dda0a5dd50190'/>
<id>urn:sha1:394fee4aa8d48e58cf82c72bcb9dda0a5dd50190</id>
<content type='text'>
- Related to https://github.com/ydb-platform/ydb/issues/9056
- Related to https://github.com/vityaman/ydb/issues/19

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1189
commit_hash:7f1cb1dcf0617aa2c94c3f2188fc9bd481380252
</content>
</entry>
<entry>
<title>YQL-19747 Complete after PRAGMA and multi-token names</title>
<updated>2025-04-08T13:26:47Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-04-08T13:11:56Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=2f90258cf6f1625ba0c99f6f37b6c9f336590534'/>
<id>urn:sha1:2f90258cf6f1625ba0c99f6f37b6c9f336590534</id>
<content type='text'>
- [x] Complete after PRAGMA
- [x] Complete multi-token names correctly, for example, `yt.` returns only `DisableStrict`, not `yt.DisableStrict` and `DateTime::` returns `Split`, not `DateTime::Split`.

I tried to implement it using `CompletedToken` edition, but not all completion environments support candidates with various `contextLen` (`Replxx` does not). So I decided that completions should rewrite only the current token, not sequences. For example, on `DateTime::Spl` rewrite only `Spl`. It makes sense as multi-token names have some namespace separated by a punctuation, so used types only namespace and gets names inside of it.

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1181
commit_hash:9d8967ac43b9348f6dbb53837d92a9dcc9b51f48
</content>
</entry>
<entry>
<title>YQL-19747 Complete Function Names</title>
<updated>2025-03-28T19:36:16Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-03-28T19:01:21Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=b60cb8f5ce78ae5f63304a534278e124d31398b0'/>
<id>urn:sha1:b60cb8f5ce78ae5f63304a534278e124d31398b0</id>
<content type='text'>
- Function names are suggested now
- Changed the module structure
- Checking ruleIndex independence on mode (ansi | default) via unit tests

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1163
commit_hash:1b1a27d2cff8db663c5c7e8efb57896476823315
</content>
</entry>
<entry>
<title>YQL-19747 Complete a simple type name</title>
<updated>2025-03-28T10:36:24Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-03-28T10:00:51Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=3ca316d11557273919db8a9887a7c08e4570f970'/>
<id>urn:sha1:3ca316d11557273919db8a9887a7c08e4570f970</id>
<content type='text'>
- Related to https://github.com/ydb-platform/ydb/issues/9056

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1151
commit_hash:6e1e429a2ea805016bf00a1e60b501b7fc8dc8de
</content>
</entry>
<entry>
<title>YQL-19747 Split statements</title>
<updated>2025-03-27T20:42:19Z</updated>
<author>
<name>vityaman</name>
<email>vityaman.dev@yandex.ru</email>
</author>
<published>2025-03-27T20:28:33Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=b24ce722d5cf848fcbe6c6f9b6fce9698174d3de'/>
<id>urn:sha1:b24ce722d5cf848fcbe6c6f9b6fce9698174d3de</id>
<content type='text'>
When we run completion engine on multi-statement query, where preceding statements are syntactically incorrect, `antlr4-c3` does not return candidates. Running engine only on a current statement provides a best-effort attempt to provide candidates.

- Related to https://github.com/ydb-platform/ydb/issues/9056
- Depends on https://github.com/ytsaurus/ytsaurus/pull/1127 (`ELexerFlavor`)

---

Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1144
commit_hash:0ced9443a9712191f5420246531f781ca4bc5f42
</content>
</entry>
<entry>
<title>Intermediate changes</title>
<updated>2025-02-28T17:15:53Z</updated>
<author>
<name>robot-piglet</name>
<email>robot-piglet@yandex-team.com</email>
</author>
<published>2025-02-28T16:58:58Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=77397379b6394220a2dfd2802f417cdd8c214905'/>
<id>urn:sha1:77397379b6394220a2dfd2802f417cdd8c214905</id>
<content type='text'>
commit_hash:5fc851d2c72810067fe0d407b66535b17de63129
</content>
</entry>
</feed>
