summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgvit <[email protected]>2023-11-09 11:30:00 +0300
committergvit <[email protected]>2023-11-09 11:49:21 +0300
commit02e4abc1fa5f00a207010969e130aa78c5285d1c (patch)
tree8467bfded193d112fac43af9f9c1b57dd491dc58
parent7b700ab4a13b745726d8f34d99b393ba1b5e7948 (diff)
unnest TTableConstInfo class in kqp resolve KIKIMR-19910
-rw-r--r--ydb/core/kqp/common/kqp_resolve.h170
-rw-r--r--ydb/core/kqp/executer_actor/kqp_partition_helper.cpp2
-rw-r--r--ydb/core/kqp/executer_actor/kqp_table_resolver.cpp2
-rw-r--r--ydb/core/kqp/executer_actor/kqp_tasks_graph.h4
-rw-r--r--ydb/core/kqp/query_data/kqp_prepared_query.h3
5 files changed, 89 insertions, 92 deletions
diff --git a/ydb/core/kqp/common/kqp_resolve.h b/ydb/core/kqp/common/kqp_resolve.h
index 36deda8e071..8226503d9a1 100644
--- a/ydb/core/kqp/common/kqp_resolve.h
+++ b/ydb/core/kqp/common/kqp_resolve.h
@@ -23,110 +23,108 @@ enum class ETableKind {
External
};
-class TKqpTableKeys {
-public:
- using TColumn = NSharding::TShardingBase::TColumn;
-
- struct TTableConstInfo : public TAtomicRefCount<TTableConstInfo> {
- TString Path;
- TMap<TString, TColumn> Columns;
- TVector<TString> KeyColumns;
- TVector<NScheme::TTypeInfo> KeyColumnTypes;
- ETableKind TableKind = ETableKind::Unknown;
- THashMap<TString, TString> Sequences;
- THashMap<TString, NKikimrMiniKQL::TResult> DefaultFromLiteral;
- TTableConstInfo() {}
- TTableConstInfo(const TString& path) : Path(path) {}
+struct TTableConstInfo : public TAtomicRefCount<TTableConstInfo> {
+ TString Path;
+ TMap<TString, NSharding::TShardingBase::TColumn> Columns;
+ TVector<TString> KeyColumns;
+ TVector<NScheme::TTypeInfo> KeyColumnTypes;
+ ETableKind TableKind = ETableKind::Unknown;
+ THashMap<TString, TString> Sequences;
+ THashMap<TString, NKikimrMiniKQL::TResult> DefaultFromLiteral;
- void FillColumn(const NKqpProto::TKqpPhyColumn& phyColumn) {
- if (Columns.FindPtr(phyColumn.GetId().GetName())) {
- return;
- }
+ TTableConstInfo() {}
+ TTableConstInfo(const TString& path) : Path(path) {}
- TKqpTableKeys::TColumn column;
- column.Id = phyColumn.GetId().GetId();
+ void FillColumn(const NKqpProto::TKqpPhyColumn& phyColumn) {
+ if (Columns.FindPtr(phyColumn.GetId().GetName())) {
+ return;
+ }
- if (phyColumn.GetTypeId() != NScheme::NTypeIds::Pg) {
- column.Type = NScheme::TTypeInfo(phyColumn.GetTypeId());
- } else {
- column.Type = NScheme::TTypeInfo(phyColumn.GetTypeId(),
- NPg::TypeDescFromPgTypeName(phyColumn.GetPgTypeName()));
- }
- column.NotNull = phyColumn.GetNotNull();
+ NSharding::TShardingBase::TColumn column;
+ column.Id = phyColumn.GetId().GetId();
- Columns.emplace(phyColumn.GetId().GetName(), std::move(column));
- if (!phyColumn.GetDefaultFromSequence().empty()) {
- TString seq = phyColumn.GetDefaultFromSequence();
- if (!seq.StartsWith(Path)) {
- seq = Path + "/" + seq;
- }
+ if (phyColumn.GetTypeId() != NScheme::NTypeIds::Pg) {
+ column.Type = NScheme::TTypeInfo(phyColumn.GetTypeId());
+ } else {
+ column.Type = NScheme::TTypeInfo(phyColumn.GetTypeId(),
+ NPg::TypeDescFromPgTypeName(phyColumn.GetPgTypeName()));
+ }
+ column.NotNull = phyColumn.GetNotNull();
- Sequences.emplace(phyColumn.GetId().GetName(), seq);
+ Columns.emplace(phyColumn.GetId().GetName(), std::move(column));
+ if (!phyColumn.GetDefaultFromSequence().empty()) {
+ TString seq = phyColumn.GetDefaultFromSequence();
+ if (!seq.StartsWith(Path)) {
+ seq = Path + "/" + seq;
}
- if (phyColumn.HasDefaultFromLiteral()) {
- DefaultFromLiteral.emplace(
- phyColumn.GetId().GetName(),
- phyColumn.GetDefaultFromLiteral());
- }
+ Sequences.emplace(phyColumn.GetId().GetName(), seq);
}
- void AddColumn(const TString& columnName) {
- auto& sysColumns = GetSystemColumns();
- if (Columns.FindPtr(columnName)) {
- return;
- }
-
- auto* systemColumn = sysColumns.FindPtr(columnName);
- YQL_ENSURE(systemColumn, "Unknown table column"
- << ", table: " << Path
- << ", column: " << columnName);
+ if (phyColumn.HasDefaultFromLiteral()) {
+ DefaultFromLiteral.emplace(
+ phyColumn.GetId().GetName(),
+ phyColumn.GetDefaultFromLiteral());
+ }
+ }
- TKqpTableKeys::TColumn column;
- column.Id = systemColumn->ColumnId;
- column.Type = NScheme::TTypeInfo(systemColumn->TypeId);
- column.NotNull = false;
- Columns.emplace(columnName, std::move(column));
+ void AddColumn(const TString& columnName) {
+ auto& sysColumns = GetSystemColumns();
+ if (Columns.FindPtr(columnName)) {
+ return;
}
+ auto* systemColumn = sysColumns.FindPtr(columnName);
+ YQL_ENSURE(systemColumn, "Unknown table column"
+ << ", table: " << Path
+ << ", column: " << columnName);
- void FillTable(const NKqpProto::TKqpPhyTable& phyTable) {
- switch (phyTable.GetKind()) {
- case NKqpProto::TABLE_KIND_DS:
- TableKind = ETableKind::Datashard;
- break;
- case NKqpProto::TABLE_KIND_OLAP:
- TableKind = ETableKind::Olap;
- break;
- case NKqpProto::TABLE_KIND_SYS_VIEW:
- TableKind = ETableKind::SysView;
- break;
- case NKqpProto::TABLE_KIND_EXTERNAL:
- TableKind = ETableKind::External;
- return;
- default:
- YQL_ENSURE(false, "Unexpected phy table kind: " << (i64) phyTable.GetKind());
- }
+ NSharding::TShardingBase::TColumn column;
+ column.Id = systemColumn->ColumnId;
+ column.Type = NScheme::TTypeInfo(systemColumn->TypeId);
+ column.NotNull = false;
+ Columns.emplace(columnName, std::move(column));
+ }
- for (const auto& [_, phyColumn] : phyTable.GetColumns()) {
- FillColumn(phyColumn);
- }
+ void FillTable(const NKqpProto::TKqpPhyTable& phyTable) {
+ switch (phyTable.GetKind()) {
+ case NKqpProto::TABLE_KIND_DS:
+ TableKind = ETableKind::Datashard;
+ break;
+ case NKqpProto::TABLE_KIND_OLAP:
+ TableKind = ETableKind::Olap;
+ break;
+ case NKqpProto::TABLE_KIND_SYS_VIEW:
+ TableKind = ETableKind::SysView;
+ break;
+ case NKqpProto::TABLE_KIND_EXTERNAL:
+ TableKind = ETableKind::External;
+ return;
+ default:
+ YQL_ENSURE(false, "Unexpected phy table kind: " << (i64) phyTable.GetKind());
+ }
- YQL_ENSURE(KeyColumns.empty());
- KeyColumns.reserve(phyTable.KeyColumnsSize());
- YQL_ENSURE(KeyColumnTypes.empty());
- KeyColumnTypes.reserve(phyTable.KeyColumnsSize());
- for (const auto& keyColumnId : phyTable.GetKeyColumns()) {
- const auto& column = Columns.FindPtr(keyColumnId.GetName());
- YQL_ENSURE(column);
+ for (const auto& [_, phyColumn] : phyTable.GetColumns()) {
+ FillColumn(phyColumn);
+ }
- KeyColumns.push_back(keyColumnId.GetName());
- KeyColumnTypes.push_back(column->Type);
- }
+ YQL_ENSURE(KeyColumns.empty());
+ KeyColumns.reserve(phyTable.KeyColumnsSize());
+ YQL_ENSURE(KeyColumnTypes.empty());
+ KeyColumnTypes.reserve(phyTable.KeyColumnsSize());
+ for (const auto& keyColumnId : phyTable.GetKeyColumns()) {
+ const auto& column = Columns.FindPtr(keyColumnId.GetName());
+ YQL_ENSURE(column);
+
+ KeyColumns.push_back(keyColumnId.GetName());
+ KeyColumnTypes.push_back(column->Type);
}
- };
+ }
+};
+class TKqpTableKeys {
+public:
struct TTable {
private:
TIntrusivePtr<TTableConstInfo> TableConstInfo;
@@ -142,7 +140,7 @@ public:
return TableConstInfo->Path;
}
- const TMap<TString, TColumn>& GetColumns() const {
+ const TMap<TString, NSharding::TShardingBase::TColumn>& GetColumns() const {
return TableConstInfo->Columns;
}
diff --git a/ydb/core/kqp/executer_actor/kqp_partition_helper.cpp b/ydb/core/kqp/executer_actor/kqp_partition_helper.cpp
index 61e867999fd..8c9b3e9a075 100644
--- a/ydb/core/kqp/executer_actor/kqp_partition_helper.cpp
+++ b/ydb/core/kqp/executer_actor/kqp_partition_helper.cpp
@@ -111,7 +111,7 @@ THashMap<ui64, TShardParamValuesAndRanges> PartitionParamByKey(
THashMap<ui64, TShardParamValuesAndRanges> PartitionParamByKeyPrefix(
const NUdf::TUnboxedValue& value, NKikimr::NMiniKQL::TType* type,
- const TTableId& tableId, const TIntrusiveConstPtr<TKqpTableKeys::TTableConstInfo>& tableInfo, const TKeyDesc& key,
+ const TTableId& tableId, const TIntrusiveConstPtr<TTableConstInfo>& tableInfo, const TKeyDesc& key,
const NMiniKQL::THolderFactory&, const NMiniKQL::TTypeEnvironment& typeEnv)
{
YQL_ENSURE(tableInfo);
diff --git a/ydb/core/kqp/executer_actor/kqp_table_resolver.cpp b/ydb/core/kqp/executer_actor/kqp_table_resolver.cpp
index ace9db43d6c..3e29f7e0127 100644
--- a/ydb/core/kqp/executer_actor/kqp_table_resolver.cpp
+++ b/ydb/core/kqp/executer_actor/kqp_table_resolver.cpp
@@ -198,7 +198,7 @@ private:
}
private:
- THolder<TKeyDesc> ExtractKey(const TTableId& table, const TIntrusiveConstPtr<TKqpTableKeys::TTableConstInfo>& tableInfo, TKeyDesc::ERowOperation operation) {
+ THolder<TKeyDesc> ExtractKey(const TTableId& table, const TIntrusiveConstPtr<TTableConstInfo>& tableInfo, TKeyDesc::ERowOperation operation) {
auto range = GetFullRange(tableInfo->KeyColumnTypes.size());
return MakeHolder<TKeyDesc>(table, range.ToTableRange(), operation, tableInfo->KeyColumnTypes,
diff --git a/ydb/core/kqp/executer_actor/kqp_tasks_graph.h b/ydb/core/kqp/executer_actor/kqp_tasks_graph.h
index 5c21eebe162..b4f68ea1649 100644
--- a/ydb/core/kqp/executer_actor/kqp_tasks_graph.h
+++ b/ydb/core/kqp/executer_actor/kqp_tasks_graph.h
@@ -33,7 +33,7 @@ struct TStageInfoMeta {
TTableId TableId;
TString TablePath;
ETableKind TableKind;
- TIntrusiveConstPtr<TKqpTableKeys::TTableConstInfo> TableConstInfo;
+ TIntrusiveConstPtr<TTableConstInfo> TableConstInfo;
TIntrusiveConstPtr<NKikimr::NSchemeCache::TSchemeCacheNavigate::TColumnTableInfo> ColumnTableInfoPtr;
TVector<bool> SkipNullKeys;
@@ -259,7 +259,7 @@ void FillChannelDesc(const TKqpTasksGraph& tasksGraph, NYql::NDqProto::TChannel&
const NYql::NDq::TChannel& channel, const NKikimrConfig::TTableServiceConfig::EChannelTransportVersion chanTransportVersion);
template<typename Proto>
-TVector<TTaskMeta::TColumn> BuildKqpColumns(const Proto& op, TIntrusiveConstPtr<TKqpTableKeys::TTableConstInfo> tableInfo) {
+TVector<TTaskMeta::TColumn> BuildKqpColumns(const Proto& op, TIntrusiveConstPtr<TTableConstInfo> tableInfo) {
TVector<TTaskMeta::TColumn> columns;
columns.reserve(op.GetColumns().size());
diff --git a/ydb/core/kqp/query_data/kqp_prepared_query.h b/ydb/core/kqp/query_data/kqp_prepared_query.h
index b1d07486da1..43e7f627b67 100644
--- a/ydb/core/kqp/query_data/kqp_prepared_query.h
+++ b/ydb/core/kqp/query_data/kqp_prepared_query.h
@@ -33,7 +33,7 @@ struct TPhyTxResultMetadata {
};
struct TTableConstInfoMap : public TAtomicRefCount<TTableConstInfoMap> {
- THashMap<TTableId, TIntrusivePtr<TKqpTableKeys::TTableConstInfo>> Map;
+ THashMap<TTableId, TIntrusivePtr<TTableConstInfo>> Map;
};
class TKqpPhyTxHolder {
@@ -127,7 +127,6 @@ public:
class TPreparedQueryHolder {
private:
- using TTableConstInfo = TKqpTableKeys::TTableConstInfo;
YDB_ACCESSOR_DEF(TLlvmSettings, LlvmSettings);
std::shared_ptr<const NKikimrKqp::TPreparedQuery> Proto;