Skip to content

Commit c25394c

Browse files
GrigoriyPAgithub-actions[bot]
authored andcommitted
YQ-4235 supported runtime results for script executions (#17421)
1 parent b9625de commit c25394c

File tree

12 files changed

+206
-12
lines changed

12 files changed

+206
-12
lines changed

.github/import_generation.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12

.github/last_commit.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
04801c0ba7d7f9f55f7bd7681dd03a87c221d8c2

.github/scripts/copy_sources.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/bash
2+
3+
tmp_dir=$(mktemp -d)
4+
5+
echo "Copying sources..."
6+
7+
cp -r $1/ydb/public/sdk/cpp/* $tmp_dir
8+
echo "tmp_dir: $tmp_dir"
9+
10+
rm -r $tmp_dir/client
11+
rm -r $tmp_dir/src/client/cms
12+
rm -r $tmp_dir/src/client/config
13+
rm -r $tmp_dir/src/client/debug
14+
rm -r $tmp_dir/src/client/draft
15+
16+
rm -r $tmp_dir/include/ydb-cpp-sdk/client/cms
17+
rm -r $tmp_dir/include/ydb-cpp-sdk/client/config
18+
rm -r $tmp_dir/include/ydb-cpp-sdk/client/debug
19+
rm -r $tmp_dir/include/ydb-cpp-sdk/client/draft
20+
21+
rm -r $tmp_dir/tests/unit/client/draft
22+
23+
mkdir -p $tmp_dir/src/api/client/yc_private
24+
mkdir -p $tmp_dir/src/api/client/yc_public
25+
26+
cp -r $1/ydb/public/api/client/yc_private/iam $tmp_dir/src/api/client/yc_private
27+
cp -r $1/ydb/public/api/client/yc_private/operation $tmp_dir/src/api/client/yc_private
28+
cp -r $1/ydb/public/api/client/yc_public/common $tmp_dir/src/api/client/yc_public
29+
cp -r $1/ydb/public/api/client/yc_public/iam $tmp_dir/src/api/client/yc_public
30+
cp -r $1/ydb/public/api/grpc $tmp_dir/src/api
31+
cp -r $1/ydb/public/api/protos $tmp_dir/src/api
32+
33+
rm -r $tmp_dir/src/api/protos/out
34+
rm $tmp_dir/include/ydb-cpp-sdk/type_switcher.h $tmp_dir/src/version.h
35+
36+
cp -r $2/util $tmp_dir
37+
cp -r $2/library $tmp_dir
38+
39+
cp -r $2/.devcontainer $tmp_dir
40+
cp -r $2/.git $tmp_dir
41+
cp -r $2/.github $tmp_dir
42+
cp -r $2/contrib $tmp_dir
43+
cp -r $2/cmake $tmp_dir
44+
cp -r $2/scripts $tmp_dir
45+
cp -r $2/third_party $tmp_dir
46+
cp -r $2/tools $tmp_dir
47+
48+
cp $2/.gitignore $tmp_dir
49+
cp $2/.gitmodules $tmp_dir
50+
cp $2/CMakePresets.json $tmp_dir
51+
cp $2/CMakeLists.txt $tmp_dir
52+
cp $2/LICENSE $tmp_dir
53+
cp $2/README.md $tmp_dir
54+
55+
cp $2/include/ydb-cpp-sdk/type_switcher.h $tmp_dir/include/ydb-cpp-sdk/type_switcher.h
56+
cp $2/src/version.h $tmp_dir/src/version.h
57+
58+
cd $2
59+
60+
find src/ include/ tests/ examples/ -type f -name "CMakeLists.txt" | while read f;
61+
do
62+
mkdir -p "$(dirname "$tmp_dir/$f")" && cp -p $f $tmp_dir/$f
63+
done
64+
65+
cd -
66+
67+
echo "Copying completed"
68+
echo "Patching sources..."
69+
70+
rm -rf $tmp_dir/adapters $tmp_dir/client
71+
72+
SED_INCLUDE='(^\s*#include\s*)(<|\")'
73+
74+
find $tmp_dir -type f -regex ".*\(h\|cpp\|cpp.in\|c\|ipp\|jnj\|rl6\|h.txt\|proto\)$" | while read f;
75+
do
76+
sed -i -E \
77+
's/'$SED_INCLUDE'ydb\/public\/api\//\1\2src\/api\//g;
78+
s/(^\s*import\s*)(\")ydb\/public\/api\//\1\2src\/api\//g;
79+
s/'$SED_INCLUDE'ydb\/public\/sdk\/cpp\/include\//\1\2/g;
80+
s/'$SED_INCLUDE'ydb\/public\/sdk\/cpp\//\1\2/g;
81+
s/'$SED_INCLUDE'library\/cpp\/retry\/retry_policy\.h/\1\2ydb-cpp-sdk\/library\/retry\/retry_policy\.h/g;
82+
s/'$SED_INCLUDE'library\/cpp\/string_utils\/base64\/base64\.h/\1\2src\/library\/string_utils\/base64\/base64\.h/g;
83+
s/(inline\s*)Dev/\1V3/g;
84+
s/(inline\s*namespace\s*)Dev/\1V3/g;' $f
85+
done
86+
87+
echo "Patching completed"
88+
echo "RSync..."
89+
90+
rsync -c -I -W -r --delete --filter '- **/ya.make' --filter '- sdk_common.inc' $tmp_dir/ $2
91+
rm -rf $tmp_dir
92+
93+
echo "RSync completed"

.github/workflows/examples.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ jobs:
3535
options: '-h localhost'
3636
steps:
3737
- name: Checkout PR
38-
uses: actions/checkout@v3
38+
uses: actions/checkout@v4
3939
if: github.event.pull_request.head.sha != ''
4040
with:
4141
submodules: true
4242
ref: ${{ github.event.pull_request.head.sha }}
4343
- name: Checkout
44-
uses: actions/checkout@v3
44+
uses: actions/checkout@v4
4545
if: github.event.pull_request.head.sha == ''
4646
with:
4747
submodules: true

.github/workflows/import.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Import
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
import-ydb-sdk:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout ydb-cpp-sdk
11+
uses: actions/checkout@v4
12+
with:
13+
submodules: true
14+
path: ydb-cpp-sdk
15+
16+
- name: Checkout ydb
17+
uses: actions/checkout@v4
18+
with:
19+
repository: ydb-platform/ydb
20+
ref: main
21+
fetch-depth: 0
22+
submodules: true
23+
path: ydb
24+
25+
- name: Sync commits
26+
run: |
27+
sudo apt-get -y update
28+
sudo apt-get -y install rsync
29+
30+
git config --global user.name "github-actions[bot]"
31+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
32+
33+
LAST_COMMIT=$(cat ydb-cpp-sdk/.github/last_commit.txt)
34+
35+
COMMITS=$(git -C ydb log --format="%H" --reverse $LAST_COMMIT..main -- ydb/public/sdk/cpp ydb/public/api)
36+
if [ -z "$COMMITS" ]; then
37+
echo "No new commits to import"
38+
exit 0
39+
fi
40+
41+
GENERATION=$(cat ydb-cpp-sdk/.github/import_generation.txt)
42+
43+
git -C ydb-cpp-sdk checkout -b import-pr-$GENERATION
44+
for commit in $COMMITS; do
45+
echo "Importing commit: $commit"
46+
git -C ydb checkout $commit
47+
ydb-cpp-sdk/.github/scripts/copy_sources.sh ydb ydb-cpp-sdk
48+
if [ -z "$(git -C ydb-cpp-sdk status --porcelain)" ]; then
49+
echo "No changes for commit: $commit"
50+
continue
51+
fi
52+
echo $commit > ydb-cpp-sdk/.github/last_commit.txt
53+
54+
message=$(git -C ydb show -s --format='%s')
55+
56+
git -C ydb-cpp-sdk add .
57+
git -C ydb-cpp-sdk status
58+
59+
git -C ydb-cpp-sdk commit --author="$(git -C ydb show -s --format='%an <%ae>' $commit)" -m "$message" --no-edit
60+
61+
git -C ydb-cpp-sdk show -s --pretty=medium
62+
done
63+
64+
- name: Create Pull Request
65+
run: |
66+
cd ydb-cpp-sdk
67+
sudo apt-get -y install gh
68+
69+
GENERATION=$(cat .github/import_generation.txt)
70+
71+
echo "$((GENERATION + 1))" > .github/import_generation.txt
72+
73+
git add .github/import_generation.txt
74+
git commit -m "Update import generation: $GENERATION"
75+
76+
git remote add token-origin https://${{ secrets.GITHUB_TOKEN }}@github.com/ydb-platform/ydb-cpp-sdk.git
77+
git push token-origin import-pr-$GENERATION
78+
79+
gh pr create \
80+
--base main \
81+
--head import-pr-$GENERATION \
82+
--title "Import YDB C++ SDK $GENERATION" \
83+
--body "Automatic import of new commits from ydb repository"
84+
env:
85+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424
runs-on: ubuntu-22.04
2525
steps:
2626
- name: Checkout PR
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828
if: github.event.pull_request.head.sha != ''
2929
with:
3030
submodules: true
3131
ref: ${{ github.event.pull_request.head.sha }}
3232
- name: Checkout
33-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
3434
if: github.event.pull_request.head.sha == ''
3535
with:
3636
submodules: true
@@ -84,13 +84,13 @@ jobs:
8484
options: '-h localhost'
8585
steps:
8686
- name: Checkout PR
87-
uses: actions/checkout@v3
87+
uses: actions/checkout@v4
8888
if: github.event.pull_request.head.sha != ''
8989
with:
9090
submodules: true
9191
ref: ${{ github.event.pull_request.head.sha }}
9292
- name: Checkout
93-
uses: actions/checkout@v3
93+
uses: actions/checkout@v4
9494
if: github.event.pull_request.head.sha == ''
9595
with:
9696
submodules: true

.github/workflows/warmup_cache.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ jobs:
1414
compiler: [clang, gcc]
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v3
18-
if: github.event.pull_request.head.sha == ''
17+
uses: actions/checkout@v4
1918
with:
2019
submodules: true
2120
- name: Install dependencies

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ _deps
2020
!*/
2121
# Unignore all files inside canondata dir
2222
!*/canondata/*
23-
23+
# Unignore all files inside .github dir
24+
!*/.github/*
2425
# C libraries
2526
*.so
2627
*.a

include/ydb-cpp-sdk/client/proto/accessor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <src/api/protos/draft/ydb_replication.pb.h>
4+
#include <src/api/protos/draft/ydb_view.pb.h>
35
#include <src/api/protos/ydb_coordination.pb.h>
46
#include <src/api/protos/ydb_export.pb.h>
57
#include <src/api/protos/ydb_import.pb.h>
@@ -8,6 +10,8 @@
810
#include <src/api/protos/ydb_topic.pb.h>
911
#include <src/api/protos/ydb_value.pb.h>
1012

13+
#include <ydb-cpp-sdk/client/draft/ydb_replication.h>
14+
#include <ydb-cpp-sdk/client/draft/ydb_view.h>
1115
#include <ydb-cpp-sdk/client/coordination/coordination.h>
1216
#include <ydb-cpp-sdk/client/export/export.h>
1317
#include <ydb-cpp-sdk/client/import/import.h>
@@ -45,6 +49,8 @@ class TProtoAccessor {
4549
static const Ydb::Topic::DescribeConsumerResult& GetProto(const NYdb::NTopic::TConsumerDescription& consumerDescription);
4650
static const Ydb::Monitoring::SelfCheckResult& GetProto(const NYdb::NMonitoring::TSelfCheckResult& selfCheckResult);
4751
static const Ydb::Coordination::DescribeNodeResult& GetProto(const NYdb::NCoordination::TNodeDescription &describeNodeResult);
52+
static const Ydb::Replication::DescribeReplicationResult& GetProto(const NYdb::NReplication::TDescribeReplicationResult& desc);
53+
static const Ydb::View::DescribeViewResult& GetProto(const NYdb::NView::TDescribeViewResult& desc);
4854

4955
static NTable::TQueryStats FromProto(const Ydb::TableStats::QueryStats& queryStats);
5056
static NTable::TTableDescription FromProto(const Ydb::Table::CreateTableRequest& request);

include/ydb-cpp-sdk/client/query/query.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,21 @@ class TResultSetMeta {
124124
public:
125125
TResultSetMeta() = default;
126126

127-
explicit TResultSetMeta(const std::vector<TColumn>& columns)
127+
explicit TResultSetMeta(const std::vector<TColumn>& columns, uint64_t rowsCount = 0, bool finished = false)
128128
: Columns(columns)
129+
, RowsCount(rowsCount)
130+
, Finished(finished)
129131
{}
130132

131-
explicit TResultSetMeta(std::vector<TColumn>&& columns)
133+
explicit TResultSetMeta(std::vector<TColumn>&& columns, uint64_t rowsCount = 0, bool finished = false)
132134
: Columns(std::move(columns))
135+
, RowsCount(rowsCount)
136+
, Finished(finished)
133137
{}
134138

135139
std::vector<TColumn> Columns;
140+
uint64_t RowsCount = 0;
141+
bool Finished = false;
136142
};
137143

138144
class TScriptExecutionOperation : public TOperation {

src/api/protos/ydb_query.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ message ExecuteQueryRequest {
186186

187187
message ResultSetMeta {
188188
repeated Ydb.Column columns = 1;
189+
uint64 number_rows = 2;
190+
bool finished = 3;
189191
}
190192

191193
message ExecuteQueryResponsePart {

src/client/query/query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ TScriptExecutionOperation::TScriptExecutionOperation(TStatus&& status, Ydb::Oper
5353
for (const auto& column : resultSetMeta.columns()) {
5454
columns.emplace_back(column.name(), column.type());
5555
}
56-
Metadata_.ResultSetsMeta.emplace_back(std::move(columns));
56+
Metadata_.ResultSetsMeta.emplace_back(std::move(columns), resultSetMeta.number_rows(), resultSetMeta.finished());
5757
}
5858

5959
if (metadata.has_script_content()) {

0 commit comments

Comments
 (0)