Skip to content

Commit 2170493

Browse files
author
dave11ar
committed
YT-20983: Add dynamic tables versioned map reduce read
12c8b4a9cd18c32a89bb2bc6d78fd4dc0f1da7b5
1 parent 9b7b894 commit 2170493

File tree

12 files changed

+88
-47
lines changed

12 files changed

+88
-47
lines changed

yt/yt/client/api/rpc_proxy/helpers.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -619,22 +619,6 @@ void FromProto(
619619
FromProto(&statistics->InnerStatistics, protoStatistics.inner_statistics());
620620
}
621621

622-
void ToProto(
623-
NProto::TVersionedReadOptions* protoOptions,
624-
const NTableClient::TVersionedReadOptions& options)
625-
{
626-
protoOptions->set_read_mode(static_cast<i32>(options.ReadMode));
627-
}
628-
629-
void FromProto(
630-
NTableClient::TVersionedReadOptions* options,
631-
const NProto::TVersionedReadOptions& protoOptions)
632-
{
633-
if (protoOptions.has_read_mode()) {
634-
options->ReadMode = CheckedEnumCast<EVersionedIOMode>(protoOptions.read_mode());
635-
}
636-
}
637-
638622
void ToProto(NProto::TOperation* protoOperation, const NApi::TOperation& operation)
639623
{
640624
protoOperation->Clear();

yt/yt/client/api/rpc_proxy/helpers.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ void FromProto(
136136
NQueryClient::TQueryStatistics* statistics,
137137
const NProto::TQueryStatistics& protoStatistics);
138138

139-
void ToProto(
140-
NProto::TVersionedReadOptions* protoOptions,
141-
const NTableClient::TVersionedReadOptions& options);
142-
143-
void FromProto(
144-
NTableClient::TVersionedReadOptions* options,
145-
const NProto::TVersionedReadOptions& protoOptions);
146-
147139
void ToProto(
148140
NProto::TOperation* protoOperation,
149141
const NApi::TOperation& operation);

yt/yt/client/table_client/public.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class THunkChunkRef;
4646
class TColumnMetaExt;
4747
class TVersionedRowDigestExt;
4848
class TCompressionDictionaryExt;
49+
class TVersionedReadOptions;
4950

5051
} // namespace NProto
5152

yt/yt/client/table_client/schema.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ TKeyColumns TTableSchema::GetKeyColumns() const
799799

800800
int TTableSchema::GetColumnCount() const
801801
{
802-
return static_cast<int>(Columns().size());
802+
return ssize(Columns());
803803
}
804804

805805
std::vector<TString> TTableSchema::GetColumnNames() const
@@ -1739,7 +1739,8 @@ void ValidateDynamicTableKeyColumnCount(int count)
17391739
void ValidateSystemColumnSchema(
17401740
const TColumnSchema& columnSchema,
17411741
bool isTableSorted,
1742-
bool allowUnversionedUpdateColumns)
1742+
bool allowUnversionedUpdateColumns,
1743+
bool allowTimestampColumns)
17431744
{
17441745
static const auto allowedSortedTablesSystemColumns = THashMap<TString, ESimpleLogicalValueType>{
17451746
{EmptyValueColumnName, ESimpleLogicalValueType::Int64},
@@ -1793,6 +1794,13 @@ void ValidateSystemColumnSchema(
17931794
}
17941795
}
17951796

1797+
if (allowTimestampColumns) {
1798+
if (name.StartsWith(TimestampColumnPrefix)) {
1799+
validateType(ESimpleLogicalValueType::Uint64);
1800+
return;
1801+
}
1802+
}
1803+
17961804
// Unexpected system column.
17971805
THROW_ERROR_EXCEPTION("System column name %Qv is not allowed here",
17981806
name);
@@ -1816,7 +1824,8 @@ void ValidateColumnSchema(
18161824
const TColumnSchema& columnSchema,
18171825
bool isTableSorted,
18181826
bool isTableDynamic,
1819-
bool allowUnversionedUpdateColumns)
1827+
bool allowUnversionedUpdateColumns,
1828+
bool allowTimestampColumns)
18201829
{
18211830
static const auto allowedAggregates = THashSet<TString>{
18221831
"sum",
@@ -1842,7 +1851,11 @@ void ValidateColumnSchema(
18421851
ValidateColumnName(name);
18431852

18441853
if (stableName.Underlying().StartsWith(SystemColumnNamePrefix) || name.StartsWith(SystemColumnNamePrefix)) {
1845-
ValidateSystemColumnSchema(columnSchema, isTableSorted, allowUnversionedUpdateColumns);
1854+
ValidateSystemColumnSchema(
1855+
columnSchema,
1856+
isTableSorted,
1857+
allowUnversionedUpdateColumns,
1858+
allowTimestampColumns);
18461859
}
18471860

18481861
{
@@ -2173,15 +2186,20 @@ void ValidateSchemaAttributes(const TTableSchema& schema)
21732186
}
21742187
}
21752188

2176-
void ValidateTableSchema(const TTableSchema& schema, bool isTableDynamic, bool allowUnversionedUpdateColumns)
2189+
void ValidateTableSchema(
2190+
const TTableSchema& schema,
2191+
bool isTableDynamic,
2192+
bool allowUnversionedUpdateColumns,
2193+
bool allowTimestampColumns)
21772194
{
21782195
int totalTypeComplexity = 0;
21792196
for (const auto& column : schema.Columns()) {
21802197
ValidateColumnSchema(
21812198
column,
21822199
schema.IsSorted(),
21832200
isTableDynamic,
2184-
allowUnversionedUpdateColumns);
2201+
allowUnversionedUpdateColumns,
2202+
allowTimestampColumns);
21852203
if (!schema.GetStrict() && column.IsRenamed()) {
21862204
THROW_ERROR_EXCEPTION("Renamed column %v in non-strict schema",
21872205
column.GetDiagnosticNameString());

yt/yt/client/table_client/schema.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,14 @@ void ValidateColumnSchema(
500500
const TColumnSchema& columnSchema,
501501
bool isTableSorted = false,
502502
bool isTableDynamic = false,
503-
bool allowUnversionedUpdateColumns = false);
503+
bool allowUnversionedUpdateColumns = false,
504+
bool allowTimestampColumns = false);
504505

505506
void ValidateTableSchema(
506507
const TTableSchema& schema,
507508
bool isTableDynamic = false,
508-
bool allowUnversionedUpdateColumns = false);
509+
bool allowUnversionedUpdateColumns = false,
510+
bool allowTimestampColumns = false);
509511

510512
void ValidateNoDescendingSortOrder(const TTableSchema& schema);
511513

yt/yt/client/table_client/versioned_io_options.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "versioned_io_options.h"
22

3+
#include <yt_proto/yt/client/table_client/proto/versioned_io_options.pb.h>
4+
35
namespace NYT::NTableClient {
46

57
////////////////////////////////////////////////////////////////////////////////
@@ -10,6 +12,20 @@ void TVersionedReadOptions::Register(TRegistrar registrar)
1012
.Default(EVersionedIOMode::Default);
1113
}
1214

15+
void ToProto(
16+
NProto::TVersionedReadOptions* protoOptions,
17+
const TVersionedReadOptions& options)
18+
{
19+
protoOptions->set_read_mode(static_cast<i32>(options.ReadMode));
20+
}
21+
22+
void FromProto(
23+
TVersionedReadOptions* options,
24+
const NProto::TVersionedReadOptions& protoOptions)
25+
{
26+
options->ReadMode = CheckedEnumCast<EVersionedIOMode>(protoOptions.read_mode());
27+
}
28+
1329
std::optional<TString> GetTimestampColumnOriginalNameOrNull(TStringBuf name)
1430
{
1531
auto prefixEnd = name.begin() + ssize(TimestampColumnPrefix);

yt/yt/client/table_client/versioned_io_options.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ struct TVersionedReadOptions
2323
static void Register(TRegistrar registrar);
2424
};
2525

26+
void ToProto(
27+
NProto::TVersionedReadOptions* protoOptions,
28+
const NTableClient::TVersionedReadOptions& options);
29+
30+
void FromProto(
31+
NTableClient::TVersionedReadOptions* options,
32+
const NProto::TVersionedReadOptions& protoOptions);
33+
2634
std::optional<TString> GetTimestampColumnOriginalNameOrNull(TStringBuf name);
2735

2836
////////////////////////////////////////////////////////////////////////////////

yt/yt/client/ypath/rich.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <yt/yt/client/table_client/column_sort_schema.h>
88
#include <yt/yt/client/table_client/column_rename_descriptor.h>
99
#include <yt/yt/client/table_client/schema.h>
10+
#include <yt/yt/client/table_client/versioned_io_options.h>
1011

1112
#include <yt/yt/core/misc/error.h>
1213

@@ -679,6 +680,11 @@ bool TRichYPath::GetCreate() const
679680
return GetAttribute<bool>(*this, "create", false);
680681
}
681682

683+
TVersionedReadOptions TRichYPath::GetVersionedReadOptions() const
684+
{
685+
return GetAttribute(*this, "versioned_read_options", TVersionedReadOptions());
686+
}
687+
682688
////////////////////////////////////////////////////////////////////////////////
683689

684690
TString ConvertToString(const TRichYPath& path, EYsonFormat ysonFormat)
@@ -779,6 +785,7 @@ const std::vector<TString>& GetWellKnownRichYPathAttributes()
779785
"clusters",
780786
"create",
781787
"read_via_exec_node",
788+
"versioned_read_options",
782789
};
783790
return WellKnownAttributes;
784791
}

yt/yt/client/ypath/rich.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
#include "public.h"
44

5-
#include <yt/yt/core/yson/public.h>
6-
7-
#include <yt/yt/core/ytree/attributes.h>
8-
9-
#include <yt/yt/core/compression/public.h>
5+
#include <yt/yt/client/chunk_client/read_limit.h>
106

11-
#include <yt/yt/library/erasure/public.h>
7+
#include <yt/yt/client/security_client/public.h>
128

139
#include <yt/yt/client/table_client/column_sort_schema.h>
1410
#include <yt/yt/client/table_client/schema.h>
1511

16-
#include <yt/yt/client/chunk_client/read_limit.h>
17-
1812
#include <yt/yt/client/transaction_client/public.h>
1913

20-
#include <yt/yt/client/security_client/public.h>
14+
#include <yt/yt/core/yson/public.h>
15+
16+
#include <yt/yt/core/ytree/attributes.h>
17+
18+
#include <yt/yt/core/compression/public.h>
19+
20+
#include <yt/yt/library/erasure/public.h>
2121

2222
namespace NYT::NYPath {
2323

@@ -167,6 +167,9 @@ class TRichYPath
167167
// "create"
168168
bool GetCreate() const;
169169

170+
// "versioned_read_options"
171+
NTableClient::TVersionedReadOptions GetVersionedReadOptions() const;
172+
170173
private:
171174
TYPath Path_;
172175
NYTree::IAttributeDictionaryPtr Attributes_;

yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import "yt_proto/yt/core/ytree/proto/request_complexity_limits.proto";
1414
import "yt_proto/yt/client/chunk_client/proto/data_statistics.proto";
1515
import "yt_proto/yt/client/chaos_client/proto/replication_card.proto";
1616
import "yt_proto/yt/client/hive/proto/timestamp_map.proto";
17+
import "yt_proto/yt/client/table_client/proto/versioned_io_options.proto";
1718
import "yt_proto/yt/client/tablet_client/proto/lock_mask.proto";
1819

1920
////////////////////////////////////////////////////////////////////////////////
@@ -608,11 +609,6 @@ message TQueryStatistics
608609
repeated TQueryStatistics inner_statistics = 14;
609610
}
610611

611-
message TVersionedReadOptions
612-
{
613-
optional int32 read_mode = 1; // EVersionedIOMode
614-
}
615-
616612
message TReqSelectRows
617613
{
618614
required string query = 1;
@@ -640,7 +636,7 @@ message TReqSelectRows
640636
optional bool merge_versioned_rows = 21;
641637
optional int32 syntax_version = 22 [default = 1];
642638
optional int32 execution_backend = 23; // EExecutionBackend
643-
optional TVersionedReadOptions versioned_read_options = 25;
639+
optional NYT.NTableClient.NProto.TVersionedReadOptions versioned_read_options = 25;
644640

645641
optional TSuppressableAccessTrackingOptions suppressable_access_tracking_options = 104;
646642

0 commit comments

Comments
 (0)