aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/complete/syntax
Commit message (Collapse)AuthorAgeFilesLines
* YQL-19747: Recover from unclosed ID_QUOTEDvityaman10 days3-6/+16
| | | | | | | | | | | | | | | | The simplest solution actually is an SQL injection. --- - Related to `YQL-19747` - Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/ydb-platform/ydb/pull/18146 - Related to https://github.com/vityaman/ydb/issues/46 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1283 commit_hash:7043e7cdd1e0d378926783d31cf5f8e055393aaa
* YQL-19747: Support USE statementvityaman10 days1-0/+4
| | | | | | | | | | | | | | Introduce global analysis which will be extended with more ParseTree analysis later. --- - Related to `YQL-19747` - Related to https://github.com/vityaman/ydb/issues/40 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1281 commit_hash:848fb3fdd6bc9612769c47d66198fca018ff465f
* YQL-19747: Fix unquoted object path completionvityaman11 days2-3/+8
| | | | | | | | | | | | | | | | On `SELECT * FROM pn` it completed to `SELECT * FROM ppnv1`, but expected ``` SELECT * FROM `pnv1` ```. --- - Related to `YQL-19747` - Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/vityaman/ydb/issues/44 - Related to https://github.com/ydb-platform/ydb/pull/18146 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1280 commit_hash:e937239fae7bf609bde6358b9b27c2b504c8ba32
* YQL-19747: Ignore type_id completions and table_keyvityaman2025-05-161-0/+2
| | | | | | | | | | | | | | Fixes superfluous candidates (`OPTIONAL`, `CALLABLE`, ...) at `SELECT * FROM #`. --- - Related to `YQL-19747` - Related to https://github.com/ydb-platform/ydb/issues/9056 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1273 commit_hash:d34d81ea86b8b6b5d339174be20d14d0371c3de6
* YQL-19747: Complete camel case type namesvityaman2025-05-121-3/+36
| | | | | | | | | | | | --- - Related to `YQL-19747` - Related to https://github.com/vityaman/ydb/issues/8 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1268 commit_hash:76e4e2c8b225994cc842c1ee00a0ec8e6eed5c05
* YQL-19747: Fix caret token positionvityaman2025-05-121-1/+18
| | | | | | | | | | | | | | | | | | | | Outcomes: 1. Need to think more deeply about library interfaces. If you think that an interface is redundant, think again, because author knows a usecase that you do not imagine. 2. If you are lazy now to implement something robustly, think twice because the day will come and this code will fire. The problem was that on input ``` ... cluster.`/yql/t#` ``` C3 receives only a prefix ``` ... cluster.`/yql/t ``` and a token stream produced was incorrect and therefore completions too. --- - Related to `YQL-19747` - Related to https://github.com/ytsaurus/ytsaurus/pull/1257 - Related to https://github.com/ydb-platform/ydb/issues/9056 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1271 commit_hash:8bf5f2683c9e41963003da923f255f63b898aac5
* YQL-19747 Complete folder, table and cluster namesvityaman2025-05-0614-188/+489
| | | | | | | | | | | | | | | | --- - 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
* YQL-19747 Use TMaybevityaman2025-04-284-14/+17
| | | | | | | | | | | | | | Just replaced `std::optional` usages with `TMaybe` to prevent this refactoring noise in future PRs. --- - Related to `YQL-19747` - Related to https://github.com/ydb-platform/ydb/issues/9056 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1247 commit_hash:dca8a6849e5ba9cb614d8350996f9423a1dc2373
* YQL-19747: Refactor sql/v1/complete usage of Future and Ptrvityaman2025-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - [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 -> LocalSyntaxAnalysis -> 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 <vvvv@yandex-team.com> Co-authored-by: vvvv <vvvv@yandex-team.com> commit_hash:497cc081ab78bebf7354e0acfaa418d936cc8240
* YQL-19747 Detect a token at the caret positionvityaman2025-04-235-44/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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<#>` got nothing because `<>` 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
* YQL-19747 Rank keywords just by plain usagesvityaman2025-04-145-19/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - [x] Rank keywords just by plain usages - [x] `LocalSyntaxAnalysis` now returns a mapping `:: Keyword -> [Following Keywords]`. - [x] Extracted keyword sequence formatting from `syntax/local` to `syntax/format`. - [x] Extracted token display logic from `syntax/local` to `antlr4/vocabulary` as it is ANTLR dependent. --- Example ```python $ ./yql_complete <<< "select " [Keyword] CAST( [Keyword] NULL [Keyword] NOT [FunctionName] If( [FunctionName] Yson::ConvertToString( [FunctionName] Count( [FunctionName] Sum( [FunctionName] Unwrap( [FunctionName] Coalesce( [Keyword] DISTINCT [Keyword] ALL [Keyword] CASE [FunctionName] Max( [Keyword] FALSE [FunctionName] Some( ``` --- - Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/vityaman/ydb/issues/17 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1197 commit_hash:f42cb4aaffe6de7c9137069c4d9c635ee110a805
* YQL-19747 Complete read hints on PROCESS and REDUCEvityaman2025-04-102-4/+4
| | | | | | | | | | | | Forgot to support it. - Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/vityaman/ydb/issues/24 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1195 commit_hash:a2f5937dbca5712f3ecbfccdf66662ce99e70619
* YQL-19747 Complete select and insert hintsvityaman2025-04-094-11/+60
| | | | | | | | | | - 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
* YQL-19747 Complete after PRAGMA and multi-token namesvityaman2025-04-084-5/+89
| | | | | | | | | | | | - [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
* YQL-19747 Complete type name as a function argumentvityaman2025-04-073-6/+36
| | | | | | | | | | | | | | | | | As I understand, type name should not be completed at `SELECT |`, so I added a check that we are at `invoke_expr` context. Currently composite type keywords are suggested at `SELECT |` and also are uppercased. I will fix it separately when this merged during - https://github.com/users/vityaman/projects/5?pane=issue&itemId=105056723&issue=vityaman%7Cydb%7C8 --- - Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/users/vityaman/projects/5/views/1?pane=issue&itemId=105056423&issue=vityaman%7Cydb%7C7 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1182 commit_hash:e87565867cf9fa82d9ac49a88d59b293d6686fe7
* YQL-19747 Complete token sequencesvityaman2025-04-023-7/+44
| | | | | | | | | | | | | Token sequences plan - [x] [Easy] Support `GROUP BY`, `ORDER BY`. - [x] [Easy] Support `Optional<`, `List<`, `Dict<`. - [x] [Easy] Support `Avg(`, `Sum(`. --- Co-authored-by: Victor Smirnov [53015676+vityaman@users.noreply.github.com] Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1173 commit_hash:a443dec666c486fef7f891be04d68a786be83049
* YQL-19747 Introduce types and functions rankingvityaman2025-04-022-5/+4
| | | | | | | | | | | | - [x] Fix bug with incorrect no-case sorting. - [x] Get names from `sql_functions.json` and `types.json`. - [x] Add types and functions ranking according to `rules_corr_basic.json` data via a `PartialSort`. - [x] Add benchmark workspace. --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1167 commit_hash:84d93265fb69bf5651f905d6af038056657e9a16
* YQL-19747 Complete Function Namesvityaman2025-03-2811-0/+470
- 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