Skip to content

Commit 8eefc61

Browse files
authored
Allow data query for olap (#12404)
1 parent a8085bf commit 8eefc61

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

ydb/core/kqp/compile_service/kqp_compile_actor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ void ApplyServiceConfig(TKikimrConfiguration& kqpConfig, const TTableServiceConf
642642
kqpConfig.ExtractPredicateRangesLimit = serviceConfig.GetExtractPredicateRangesLimit();
643643
kqpConfig.EnablePerStatementQueryExecution = serviceConfig.GetEnablePerStatementQueryExecution();
644644
kqpConfig.EnableCreateTableAs = serviceConfig.GetEnableCreateTableAs();
645+
kqpConfig.AllowOlapDataQuery = serviceConfig.GetAllowOlapDataQuery();
645646
kqpConfig.EnableOlapSink = serviceConfig.GetEnableOlapSink();
646647
kqpConfig.EnableOltpSink = serviceConfig.GetEnableOltpSink();
647648
kqpConfig.EnableHtapTx = serviceConfig.GetEnableHtapTx();

ydb/core/kqp/compile_service/kqp_compile_service.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ class TKqpCompileService : public TActorBootstrapped<TKqpCompileService> {
295295

296296
bool enableSequences = TableServiceConfig.GetEnableSequences();
297297
bool enableColumnsWithDefault = TableServiceConfig.GetEnableColumnsWithDefault();
298+
bool allowOlapDataQuery = TableServiceConfig.GetAllowOlapDataQuery();
298299
bool enableOlapSink = TableServiceConfig.GetEnableOlapSink();
299300
bool enableOltpSink = TableServiceConfig.GetEnableOltpSink();
300301
bool enableHtapTx = TableServiceConfig.GetEnableHtapTx();
@@ -329,6 +330,7 @@ class TKqpCompileService : public TActorBootstrapped<TKqpCompileService> {
329330
TableServiceConfig.GetIndexAutoChooseMode() != indexAutoChooser ||
330331
TableServiceConfig.GetEnableSequences() != enableSequences ||
331332
TableServiceConfig.GetEnableColumnsWithDefault() != enableColumnsWithDefault ||
333+
TableServiceConfig.GetAllowOlapDataQuery() != allowOlapDataQuery ||
332334
TableServiceConfig.GetEnableOlapSink() != enableOlapSink ||
333335
TableServiceConfig.GetEnableOltpSink() != enableOltpSink ||
334336
TableServiceConfig.GetEnableHtapTx() != enableHtapTx ||

ydb/core/kqp/executer_actor/kqp_data_executer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
142142
, FederatedQuerySetup(federatedQuerySetup)
143143
, GUCSettings(GUCSettings)
144144
, ShardIdToTableInfo(shardIdToTableInfo)
145+
, AllowOlapDataQuery(tableServiceConfig.GetAllowOlapDataQuery())
145146
, BlockTrackingMode(tableServiceConfig.GetBlockTrackingMode())
146147
, WaitCAStatsTimeout(TDuration::MilliSeconds(tableServiceConfig.GetQueryLimits().GetWaitCAStatsTimeoutMs()))
147148
{
@@ -1927,7 +1928,7 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
19271928
}
19281929

19291930
bool HasDmlOperationOnOlap(NKqpProto::TKqpPhyTx_EType queryType, const NKqpProto::TKqpPhyStage& stage) {
1930-
if (queryType == NKqpProto::TKqpPhyTx::TYPE_DATA) {
1931+
if (queryType == NKqpProto::TKqpPhyTx::TYPE_DATA && !AllowOlapDataQuery) {
19311932
return true;
19321933
}
19331934

@@ -2955,6 +2956,7 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
29552956
const std::optional<TKqpFederatedQuerySetup> FederatedQuerySetup;
29562957
const TGUCSettings::TPtr GUCSettings;
29572958
TShardIdToTableInfoPtr ShardIdToTableInfo;
2959+
const bool AllowOlapDataQuery = false;
29582960

29592961
bool HasExternalSources = false;
29602962
bool SecretSnapshotRequired = false;

ydb/core/kqp/opt/kqp_opt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ bool IsKqpEffectsStage(const TDqStageBase& stage) {
8383
}
8484

8585
bool NeedSinks(const TKikimrTableDescription& table, const TKqpOptimizeContext& kqpCtx) {
86-
return (kqpCtx.IsGenericQuery() || (kqpCtx.IsDataQuery() && table.Metadata->Kind != EKikimrTableKind::Olap))
86+
return (kqpCtx.IsGenericQuery()
87+
|| (kqpCtx.IsDataQuery() && (table.Metadata->Kind != EKikimrTableKind::Olap || kqpCtx.Config->AllowOlapDataQuery)))
8788
&& (table.Metadata->Kind != EKikimrTableKind::Olap || kqpCtx.Config->EnableOlapSink)
8889
&& (table.Metadata->Kind != EKikimrTableKind::Datashard || kqpCtx.Config->EnableOltpSink);
8990
}

ydb/core/kqp/provider/yql_kikimr_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct TKikimrConfiguration : public TKikimrSettings, public NCommon::TSettingDi
168168
bool EnablePerStatementQueryExecution = false;
169169
bool EnableCreateTableAs = false;
170170
ui64 IdxLookupJoinsPrefixPointLimit = 1;
171+
bool AllowOlapDataQuery = false;
171172
bool EnableOlapSink = false;
172173
bool EnableOltpSink = false;
173174
bool EnableHtapTx = false;

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,11 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
18201820
}
18211821

18221822
void TestOlapUpsert(ui32 numShards) {
1823+
NKikimrConfig::TAppConfig appConfig;
1824+
appConfig.MutableTableServiceConfig()->SetEnableOlapSink(true);
1825+
appConfig.MutableTableServiceConfig()->SetAllowOlapDataQuery(true);
18231826
auto settings = TKikimrSettings()
1827+
.SetAppConfig(appConfig)
18241828
.SetWithSampleTables(false);
18251829
TKikimrRunner kikimr(settings);
18261830

@@ -1868,22 +1872,15 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
18681872
UNIT_ASSERT_C(it.IsSuccess(), it.GetIssues().ToString());
18691873
TString result = StreamResultToYson(it);
18701874
Cout << result << Endl;
1871-
//CompareYson(result, R"([[0;15];[1;15]])");
1872-
CompareYson(result, R"([])"); // FIXME
1875+
CompareYson(result, R"([[15;0];[15;1]])");
18731876
}
18741877
}
18751878

18761879
Y_UNIT_TEST(OlapUpsertImmediate) {
1877-
// Should be fixed in KIKIMR-17646
1878-
return;
1879-
18801880
TestOlapUpsert(1);
18811881
}
18821882

18831883
Y_UNIT_TEST(OlapUpsert) {
1884-
// Should be fixed in KIKIMR-17646
1885-
return;
1886-
18871884
TestOlapUpsert(2);
18881885
}
18891886

ydb/core/protos/table_service_config.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,6 @@ message TTableServiceConfig {
348348
}
349349

350350
optional EBlockTrackingMode BlockTrackingMode = 73 [ default = BLOCK_TRACKING_SERIALIZE ];
351+
352+
optional bool AllowOlapDataQuery = 74 [default = false];
351353
};

0 commit comments

Comments
 (0)