Skip to content

Commit b7cbbfa

Browse files
committed
Merge remote-tracking branch 'origin/YQ-RD-Add-YQL-conclusion-status' into YQ-3738-pass-UV-from-filter-to-read-actor
2 parents 3031d7b + 9a2d4eb commit b7cbbfa

File tree

25 files changed

+566
-201
lines changed

25 files changed

+566
-201
lines changed

ydb/core/kqp/gateway/behaviour/tablestore/operations/upsert_opt.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ TConclusionStatus TUpsertOptionsOperation::DoDeserialize(NYql::TObjectSettingsIm
1010
return TConclusionStatus::Fail("Incorrect value for SCHEME_NEED_ACTUALIZATION: cannot parse as boolean");
1111
}
1212
SchemeNeedActualization = *value;
13-
ExternalGuaranteeExclusivePK = features.Extract<bool>("EXTERNAL_GUARANTEE_EXCLUSIVE_PK");
13+
ScanReaderPolicyName = features.Extract<TString>("SCAN_READER_POLICY_NAME");
14+
if (ScanReaderPolicyName) {
15+
if (*ScanReaderPolicyName != "PLAIN" && *ScanReaderPolicyName != "SIMPLE") {
16+
return TConclusionStatus::Fail("SCAN_READER_POLICY_NAME have to be in ['PLAIN', 'SIMPLE']");
17+
}
18+
}
1419
if (const auto className = features.Extract<TString>("COMPACTION_PLANNER.CLASS_NAME")) {
1520
if (!CompactionPlannerConstructor.Initialize(*className)) {
1621
return TConclusionStatus::Fail("incorrect class name for compaction planner:" + *className);
@@ -52,8 +57,8 @@ TConclusionStatus TUpsertOptionsOperation::DoDeserialize(NYql::TObjectSettingsIm
5257

5358
void TUpsertOptionsOperation::DoSerializeScheme(NKikimrSchemeOp::TAlterColumnTableSchema& schemaData) const {
5459
schemaData.MutableOptions()->SetSchemeNeedActualization(SchemeNeedActualization);
55-
if (ExternalGuaranteeExclusivePK) {
56-
schemaData.MutableOptions()->SetExternalGuaranteeExclusivePK(*ExternalGuaranteeExclusivePK);
60+
if (ScanReaderPolicyName) {
61+
schemaData.MutableOptions()->SetScanReaderPolicyName(*ScanReaderPolicyName);
5762
}
5863
if (CompactionPlannerConstructor.HasObject()) {
5964
CompactionPlannerConstructor.SerializeToProto(*schemaData.MutableOptions()->MutableCompactionPlannerConstructor());

ydb/core/kqp/gateway/behaviour/tablestore/operations/upsert_opt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TUpsertOptionsOperation: public ITableStoreOperation {
1313
static inline const auto Registrator = TFactory::TRegistrator<TUpsertOptionsOperation>(GetTypeName());
1414
private:
1515
bool SchemeNeedActualization = false;
16-
std::optional<bool> ExternalGuaranteeExclusivePK;
16+
std::optional<TString> ScanReaderPolicyName;
1717
NOlap::NStorageOptimizer::TOptimizerPlannerConstructorContainer CompactionPlannerConstructor;
1818
NOlap::NDataAccessorControl::TMetadataManagerConstructorContainer MetadataManagerConstructor;
1919
public:

ydb/core/kqp/provider/yql_kikimr_datasink.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ class TKiSinkIntentDeterminationTransformer: public TKiSinkVisitorTransformer {
391391
return TStatus::Ok;
392392
case TKikimrKey::Type::BackupCollection:
393393
return TStatus::Ok;
394+
case TKikimrKey::Type::Sequence:
395+
return TStatus::Ok;
394396
}
395397

396398
ctx.AddError(TIssue(ctx.GetPosition(node.Pos()), "Invalid table key type."));
@@ -845,10 +847,21 @@ class TKikimrDataSink : public TDataProviderBase
845847
? settings.ValueType.Cast()
846848
: Build<TCoAtom>(ctx, node->Pos()).Value("Null").Done();
847849

850+
TString sequence;
851+
852+
if (key.GetKeyType() == TKikimrKey::Type::Sequence) {
853+
sequence = key.GetSequencePath();
854+
} else if (key.GetKeyType() == TKikimrKey::Type::PGObject) {
855+
sequence = key.GetPGObjectId();
856+
} else {
857+
YQL_ENSURE(false, "Invalid key type for sequence");
858+
}
859+
860+
848861
return Build<TKiAlterSequence>(ctx, node->Pos())
849862
.World(node->Child(0))
850863
.DataSink(node->Child(1))
851-
.Sequence().Build(key.GetPGObjectId())
864+
.Sequence().Build(sequence)
852865
.ValueType(valueType)
853866
.SequenceSettings(settings.SequenceSettings.Cast())
854867
.Settings(settings.Other)
@@ -1267,6 +1280,21 @@ class TKikimrDataSink : public TDataProviderBase
12671280
}
12681281
break;
12691282
}
1283+
case TKikimrKey::Type::Sequence: {
1284+
NCommon::TWriteSequenceSettings settings = NCommon::ParseSequenceSettings(TExprList(node->Child(4)), ctx);
1285+
1286+
YQL_ENSURE(settings.Mode);
1287+
auto mode = settings.Mode.Cast();
1288+
1289+
if (mode == "alter" || mode == "alter_if_exists") {
1290+
return MakeAlterSequence(node, settings, key, ctx);
1291+
} else {
1292+
ctx.AddError(TIssue(ctx.GetPosition(node->Pos()), "Unknown operation type for sequence"));
1293+
return nullptr;
1294+
}
1295+
1296+
break;
1297+
}
12701298
case TKikimrKey::Type::Object:
12711299
{
12721300
NCommon::TWriteObjectSettings settings = NCommon::ParseWriteObjectSettings(TExprList(node->Child(4)), ctx);

ydb/core/kqp/provider/yql_kikimr_datasource.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ class TKiSourceIntentDeterminationTransformer: public TKiSourceVisitorTransforme
166166
return TStatus::Ok;
167167
case TKikimrKey::Type::BackupCollection:
168168
return TStatus::Ok;
169+
case TKikimrKey::Type::Sequence:
170+
return TStatus::Ok;
169171
}
170172

171173
return TStatus::Error;

ydb/core/kqp/provider/yql_kikimr_provider.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ bool TKikimrKey::Extract(const TExprNode& key) {
440440
} else if(tagName == "permission") {
441441
KeyType = Type::Permission;
442442
Target = key.Child(0)->Child(1)->Child(0)->Content();
443+
} else if (tagName == "sequence") {
444+
KeyType = Type::Sequence;
445+
Target = key.Child(0)->Child(1)->Child(0)->Content();
443446
} else if (tagName == "pgObject") {
444447
KeyType = Type::PGObject;
445448
Target = key.Child(0)->Child(1)->Child(0)->Content();

ydb/core/kqp/provider/yql_kikimr_provider_impl.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class TKikimrKey {
9797
PGObject,
9898
Replication,
9999
BackupCollection,
100+
Sequence,
100101
};
101102

102103
struct TViewDescription {
@@ -130,6 +131,12 @@ class TKikimrKey {
130131
return Target;
131132
}
132133

134+
TString GetSequencePath() const {
135+
Y_DEBUG_ABORT_UNLESS(KeyType.Defined());
136+
Y_DEBUG_ABORT_UNLESS(KeyType == Type::Sequence);
137+
return Target;
138+
}
139+
133140
TString GetReplicationPath() const {
134141
Y_DEBUG_ABORT_UNLESS(KeyType.Defined());
135142
Y_DEBUG_ABORT_UNLESS(KeyType == Type::Replication);

ydb/core/kqp/provider/yql_kikimr_type_ann.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ class TKiSourceTypeAnnotationTransformer : public TKiSourceVisitorTransformer {
227227
{
228228
return TStatus::Ok;
229229
}
230+
case TKikimrKey::Type::Sequence:
231+
{
232+
return TStatus::Ok;
233+
}
230234
}
231235

232236
return TStatus::Error;

ydb/core/kqp/ut/olap/aggregations_ut.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,33 @@ Y_UNIT_TEST_SUITE(KqpOlapAggregations) {
7575
Cout << result << Endl;
7676
CompareYson(result, R"([[23000u;]])");
7777
}
78+
79+
{
80+
auto alterQuery = TStringBuilder() <<
81+
R"(
82+
ALTER OBJECT `/Root/olapStore` (TYPE TABLESTORE) SET (ACTION=UPSERT_OPTIONS, `SCAN_READER_POLICY_NAME`=`SIMPLE`)
83+
)";
84+
auto session = tableClient.CreateSession().GetValueSync().GetSession();
85+
auto alterResult = session.ExecuteSchemeQuery(alterQuery).GetValueSync();
86+
UNIT_ASSERT_VALUES_EQUAL_C(alterResult.GetStatus(), NYdb::EStatus::SUCCESS, alterResult.GetIssues().ToString());
87+
}
88+
89+
{
90+
auto it = tableClient
91+
.StreamExecuteScanQuery(R"(
92+
--!syntax_v1
93+
94+
SELECT
95+
COUNT(*)
96+
FROM `/Root/olapStore/olapTable`
97+
)")
98+
.GetValueSync();
99+
100+
UNIT_ASSERT_C(it.IsSuccess(), it.GetIssues().ToString());
101+
TString result = StreamResultToYson(it);
102+
Cout << result << Endl;
103+
CompareYson(result, R"([[23000u;]])");
104+
}
78105
}
79106

80107
Y_UNIT_TEST(AggregationCountPushdown) {

0 commit comments

Comments
 (0)