summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/object_processing.cpp
diff options
context:
space:
mode:
authorvvvv <[email protected]>2024-11-07 12:29:36 +0300
committervvvv <[email protected]>2024-11-07 13:49:47 +0300
commitd4c258e9431675bab6745c8638df6e3dfd4dca6b (patch)
treeb5efcfa11351152a4c872fccaea35749141c0b11 /yql/essentials/sql/v1/object_processing.cpp
parent13a4f274caef5cfdaf0263b24e4d6bdd5521472b (diff)
Moved other yql/essentials libs YQL-19206
init commit_hash:7d4c435602078407bbf20dd3c32f9c90d2bbcbc0
Diffstat (limited to 'yql/essentials/sql/v1/object_processing.cpp')
-rw-r--r--yql/essentials/sql/v1/object_processing.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/yql/essentials/sql/v1/object_processing.cpp b/yql/essentials/sql/v1/object_processing.cpp
new file mode 100644
index 00000000000..80e3962bf8d
--- /dev/null
+++ b/yql/essentials/sql/v1/object_processing.cpp
@@ -0,0 +1,68 @@
+#include "object_processing.h"
+
+#include <yql/essentials/core/sql_types/yql_callable_names.h>
+
+namespace NSQLTranslationV1 {
+using namespace NYql;
+
+INode::TPtr TObjectProcessorImpl::BuildKeys() const {
+ auto keys = Y("Key");
+ keys = L(keys, Q(Y(Q("objectId"), Y("String", BuildQuotedAtom(Pos, ObjectId)))));
+ keys = L(keys, Q(Y(Q("typeId"), Y("String", BuildQuotedAtom(Pos, TypeId)))));
+ return keys;
+}
+
+TObjectProcessorImpl::TObjectProcessorImpl(TPosition pos, const TString& objectId, const TString& typeId, const TObjectOperatorContext& context)
+ : TBase(pos)
+ , TObjectOperatorContext(context)
+ , ObjectId(objectId)
+ , TypeId(typeId)
+{
+
+}
+
+bool TObjectProcessorImpl::DoInit(TContext& ctx, ISource* src) {
+ Y_UNUSED(src);
+ Scoped->UseCluster(ServiceId, Cluster);
+ auto options = FillFeatures(BuildOptions());
+ auto keys = BuildKeys();
+
+ Add("block", Q(Y(
+ Y("let", "sink", Y("DataSink", BuildQuotedAtom(Pos, ServiceId), Scoped->WrapCluster(Cluster, ctx))),
+ Y("let", "world", Y(TString(WriteName), "world", "sink", keys, Y("Void"), Q(options))),
+ Y("return", ctx.PragmaAutoCommit ? Y(TString(CommitName), "world", "sink") : AstNode("world"))
+ )));
+ return TAstListNode::DoInit(ctx, src);
+}
+
+INode::TPtr TCreateObject::FillFeatures(INode::TPtr options) const {
+ if (!Features.empty()) {
+ auto features = Y();
+ for (auto&& i : Features) {
+ if (i.second.HasNode()) {
+ features->Add(Q(Y(BuildQuotedAtom(Pos, i.first), i.second.Build())));
+ } else {
+ features->Add(Q(Y(BuildQuotedAtom(Pos, i.first))));
+ }
+ }
+ options->Add(Q(Y(Q("features"), Q(features))));
+ }
+ if (!FeaturesToReset.empty()) {
+ auto reset = Y();
+ for (const auto& featureName : FeaturesToReset) {
+ reset->Add(BuildQuotedAtom(Pos, featureName));
+ }
+ options->Add(Q(Y(Q("resetFeatures"), Q(reset))));
+ }
+ return options;
+}
+
+TObjectOperatorContext::TObjectOperatorContext(TScopedStatePtr scoped)
+ : Scoped(scoped)
+ , ServiceId(Scoped->CurrService)
+ , Cluster(Scoped->CurrCluster)
+{
+
+}
+
+}