aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ydb/tests/tools/kqprun/.gitignore1
-rw-r--r--ydb/tests/tools/kqprun/kqprun.cpp23
-rw-r--r--ydb/tests/tools/kqprun/src/common.h1
-rw-r--r--ydb/tests/tools/kqprun/src/ydb_setup.cpp1
4 files changed, 25 insertions, 1 deletions
diff --git a/ydb/tests/tools/kqprun/.gitignore b/ydb/tests/tools/kqprun/.gitignore
index 9abcbfaefc8..0e9eea55d38 100644
--- a/ydb/tests/tools/kqprun/.gitignore
+++ b/ydb/tests/tools/kqprun/.gitignore
@@ -5,6 +5,7 @@ udfs
*.attr
*.bin
+*.conf
*.json
*.log
*.old
diff --git a/ydb/tests/tools/kqprun/kqprun.cpp b/ydb/tests/tools/kqprun/kqprun.cpp
index 2ac102bbdf0..21ed1f5d747 100644
--- a/ydb/tests/tools/kqprun/kqprun.cpp
+++ b/ydb/tests/tools/kqprun/kqprun.cpp
@@ -38,6 +38,7 @@ struct TExecutionOptions {
std::vector<TString> ScriptQueries;
TString SchemeQuery;
+ std::unordered_map<TString, Ydb::TypedValue> Params;
bool UseTemplates = false;
ui32 LoopCount = 1;
@@ -115,7 +116,8 @@ struct TExecutionOptions {
.UserSID = GetValue(index, UserSIDs, TString(BUILTIN_ACL_ROOT)),
.Database = GetValue(index, Databases, TString()),
.Timeout = GetValue(index, Timeouts, TDuration::Zero()),
- .QueryId = queryId
+ .QueryId = queryId,
+ .Params = Params
};
}
@@ -469,6 +471,25 @@ protected:
}
});
+ options.AddLongOption("param", "Add query parameter from file to -p queries, use name@file (param value is protobuf Ydb::TypedValue)")
+ .RequiredArgument("name@file")
+ .Handler1([this](const NLastGetopt::TOptsParser* option) {
+ TStringBuf name;
+ TStringBuf filePath;
+ TStringBuf(option->CurVal()).Split('@', name, filePath);
+ if (name.empty() || filePath.empty()) {
+ ythrow yexception() << "Incorrect query parameter, expected form name@file";
+ }
+
+ Ydb::TypedValue value;
+ if (!google::protobuf::TextFormat::ParseFromString(LoadFile(TString(filePath)), &value)) {
+ ythrow yexception() << "Failed to parse query parameter from file '" << filePath << "'";
+ }
+ if (!ExecutionOptions.Params.emplace(TStringBuilder() << "$" << name, value).second) {
+ ythrow yexception() << "Got duplicated parameter name '" << name << "'";
+ }
+ });
+
options.AddLongOption('t', "table", "File with input table (can be used by YT with -E flag), table@file")
.RequiredArgument("table@file")
.Handler1([this](const NLastGetopt::TOptsParser* option) {
diff --git a/ydb/tests/tools/kqprun/src/common.h b/ydb/tests/tools/kqprun/src/common.h
index a7d7064c0f4..adf3ca06990 100644
--- a/ydb/tests/tools/kqprun/src/common.h
+++ b/ydb/tests/tools/kqprun/src/common.h
@@ -85,6 +85,7 @@ struct TRequestOptions {
TString Database;
TDuration Timeout;
size_t QueryId = 0;
+ std::unordered_map<TString, Ydb::TypedValue> Params;
};
} // namespace NKqpRun
diff --git a/ydb/tests/tools/kqprun/src/ydb_setup.cpp b/ydb/tests/tools/kqprun/src/ydb_setup.cpp
index 83e2c0923dd..01c7666fcf0 100644
--- a/ydb/tests/tools/kqprun/src/ydb_setup.cpp
+++ b/ydb/tests/tools/kqprun/src/ydb_setup.cpp
@@ -540,6 +540,7 @@ private:
request->SetCollectStats(Ydb::Table::QueryStatsCollection::STATS_COLLECTION_FULL);
request->SetDatabase(database);
request->SetPoolId(query.PoolId);
+ request->MutableYdbParameters()->insert(query.Params.begin(), query.Params.end());
if (query.Timeout) {
request->SetTimeoutMs(query.Timeout.MilliSeconds());