diff options
| author | deep <[email protected]> | 2025-01-21 20:52:52 +0300 |
|---|---|---|
| committer | deep <[email protected]> | 2025-01-21 21:15:15 +0300 |
| commit | b43fa924bdf3f714f2ce7e109ed65c3a71f3e2a6 (patch) | |
| tree | 0429a3b7bc5d60d66a04d18091aa915a03f60df2 | |
| parent | 6b26b7fba89ee483b19cef1b1f9adfc50a0b882c (diff) | |
YTORM-1043 Use proto references in index lookups (great again)
Теперь можно определить индекс через reference и писать запросы в этот индекс через звёздочку.
commit_hash:147315058175b1a506e1835fc4b0612aeb775235
| -rw-r--r-- | yt/yt/core/yson/protobuf_interop.cpp | 9 | ||||
| -rw-r--r-- | yt/yt/core/yson/protobuf_interop_options.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/yt/yt/core/yson/protobuf_interop.cpp b/yt/yt/core/yson/protobuf_interop.cpp index dd019603843..12f138442b1 100644 --- a/yt/yt/core/yson/protobuf_interop.cpp +++ b/yt/yt/core/yson/protobuf_interop.cpp @@ -3051,6 +3051,11 @@ TProtobufElementResolveResult ResolveProtobufElementByYPath( } tokenizer.Advance(); + if (options.AllowAsterisks && tokenizer.GetType() == NYPath::ETokenType::Asterisk) { + tokenizer.Advance(); + tokenizer.Expect(NYPath::ETokenType::Slash); + tokenizer.Advance(); + } tokenizer.Expect(NYPath::ETokenType::Literal); const auto& fieldName = tokenizer.GetLiteralValue(); @@ -3115,7 +3120,9 @@ TProtobufElementResolveResult ResolveProtobufElementByYPath( tokenizer.Expect(NYPath::ETokenType::Slash); tokenizer.Advance(); - tokenizer.ExpectListIndex(); + if (!options.AllowAsterisks || tokenizer.GetType() != NYPath::ETokenType::Asterisk) { + tokenizer.ExpectListIndex(); + } if (!field->IsMessage()) { return GetProtobufElementFromField( diff --git a/yt/yt/core/yson/protobuf_interop_options.h b/yt/yt/core/yson/protobuf_interop_options.h index 68a45c4b296..40a53d44c7a 100644 --- a/yt/yt/core/yson/protobuf_interop_options.h +++ b/yt/yt/core/yson/protobuf_interop_options.h @@ -14,6 +14,7 @@ namespace NYT::NYson { struct TResolveProtobufElementByYPathOptions { bool AllowUnknownYsonFields = false; + bool AllowAsterisks = false; }; struct TProtobufWriterOptions |
