@@ -498,7 +498,7 @@ std::string TTableSchema::TNameMapping::StableNameToName(const TColumnStableName
498
498
{
499
499
auto * column = Schema_.FindColumnByStableName (stableName);
500
500
if (!column) {
501
- if (Schema_.GetStrict ()) {
501
+ if (Schema_.IsStrict ()) {
502
502
THROW_ERROR_EXCEPTION (" No column with stable name %Qv in strict schema" , stableName);
503
503
}
504
504
return stableName.Underlying ();
@@ -510,7 +510,7 @@ TColumnStableName TTableSchema::TNameMapping::NameToStableName(TStringBuf name)
510
510
{
511
511
auto * column = Schema_.FindColumn (name);
512
512
if (!column) {
513
- if (Schema_.GetStrict ()) {
513
+ if (Schema_.IsStrict ()) {
514
514
if (auto originalColumnName = GetTimestampColumnOriginalNameOrNull (name);
515
515
!originalColumnName || !Schema_.FindColumn (*originalColumnName))
516
516
{
@@ -759,11 +759,6 @@ bool TTableSchema::IsSorted() const
759
759
return KeyColumnCount_ > 0 ;
760
760
}
761
761
762
- bool TTableSchema::IsUniqueKeys () const
763
- {
764
- return UniqueKeys_;
765
- }
766
-
767
762
bool TTableSchema::HasRenamedColumns () const
768
763
{
769
764
return std::any_of (Columns ().begin (), Columns ().end (), [] (const TColumnSchema& column) {
@@ -873,7 +868,7 @@ std::vector<TColumnStableName> MapNamesToStableNames(
873
868
const auto * column = schema.FindColumn (name);
874
869
if (column) {
875
870
stableNames.push_back (column->StableName ());
876
- } else if (!schema.GetStrict ()) {
871
+ } else if (!schema.IsStrict ()) {
877
872
stableNames.push_back (TColumnStableName (name));
878
873
} else if (missingColumnReplacement) {
879
874
stableNames.push_back (TColumnStableName (std::string (*missingColumnReplacement)));
@@ -1496,7 +1491,7 @@ TKeyColumnTypes TTableSchema::GetKeyColumnTypes() const
1496
1491
1497
1492
void FormatValue (TStringBuilderBase* builder, const TTableSchema& schema, TStringBuf /* spec*/ )
1498
1493
{
1499
- builder->AppendFormat (" <strict=%v;unique_keys=%v" , schema.GetStrict (), schema.GetUniqueKeys ());
1494
+ builder->AppendFormat (" <strict=%v;unique_keys=%v" , schema.IsStrict (), schema.IsUniqueKeys ());
1500
1495
if (schema.HasNontrivialSchemaModification ()) {
1501
1496
builder->AppendFormat (" ;schema_modification=%v" , schema.GetSchemaModification ());
1502
1497
}
@@ -1530,10 +1525,18 @@ void FormatValue(TStringBuilderBase* builder, const TTableSchemaPtr& schema, TSt
1530
1525
}
1531
1526
1532
1527
std::string SerializeToWireProto (const TTableSchemaPtr& schema)
1528
+ {
1529
+ return schema ? SerializeToWireProto (*schema) : " " ;
1530
+ }
1531
+
1532
+ std::string SerializeToWireProto (const TTableSchema& schema)
1533
1533
{
1534
1534
NTableClient::NProto::TTableSchemaExt protoSchema;
1535
1535
ToProto (&protoSchema, schema);
1536
- return protoSchema.SerializeAsString ();
1536
+ if (protoSchema.IsInitialized ()) {
1537
+ return protoSchema.SerializeAsString ();
1538
+ }
1539
+ THROW_ERROR_EXCEPTION (" Table schema is not initialized" );
1537
1540
}
1538
1541
1539
1542
void DeserializeFromWireProto (TTableSchemaPtr* schema, const std::string& serializedProto)
@@ -1549,8 +1552,8 @@ void ToProto(NProto::TTableSchemaExt* protoSchema, const TTableSchema& schema)
1549
1552
{
1550
1553
ToProto (protoSchema->mutable_columns (), schema.Columns ());
1551
1554
ToProto (protoSchema->mutable_deleted_columns (), schema.DeletedColumns ());
1552
- protoSchema->set_strict (schema.GetStrict ());
1553
- protoSchema->set_unique_keys (schema.GetUniqueKeys ());
1555
+ protoSchema->set_strict (schema.IsStrict ());
1556
+ protoSchema->set_unique_keys (schema.IsUniqueKeys ());
1554
1557
protoSchema->set_schema_modification (ToProto (schema.GetSchemaModification ()));
1555
1558
}
1556
1559
@@ -1674,8 +1677,8 @@ bool operator==(const TTableSchema& lhs, const TTableSchema& rhs)
1674
1677
{
1675
1678
return
1676
1679
lhs.Columns () == rhs.Columns () &&
1677
- lhs.GetStrict () == rhs.GetStrict () &&
1678
- lhs.GetUniqueKeys () == rhs.GetUniqueKeys () &&
1680
+ lhs.IsStrict () == rhs.IsStrict () &&
1681
+ lhs.IsUniqueKeys () == rhs.IsUniqueKeys () &&
1679
1682
lhs.GetSchemaModification () == rhs.GetSchemaModification () &&
1680
1683
lhs.DeletedColumns () == rhs.DeletedColumns ();
1681
1684
}
@@ -1691,7 +1694,7 @@ bool IsEqualIgnoringRequiredness(const TTableSchema& lhs, const TTableSchema& rh
1691
1694
}
1692
1695
resultColumns.emplace_back (column);
1693
1696
}
1694
- return TTableSchema (resultColumns, schema.GetStrict (), schema.GetUniqueKeys ());
1697
+ return TTableSchema (resultColumns, schema.IsStrict (), schema.IsUniqueKeys ());
1695
1698
};
1696
1699
return dropRequiredness (lhs) == dropRequiredness (rhs);
1697
1700
}
@@ -2090,11 +2093,11 @@ void ValidateColumnSchema(
2090
2093
2091
2094
void ValidateDynamicTableConstraints (const TTableSchema& schema)
2092
2095
{
2093
- if (!schema.GetStrict ()) {
2096
+ if (!schema.IsStrict ()) {
2094
2097
THROW_ERROR_EXCEPTION (" \" strict\" cannot be \" false\" for a dynamic table" );
2095
2098
}
2096
2099
2097
- if (schema.IsSorted () && !schema.GetUniqueKeys ()) {
2100
+ if (schema.IsSorted () && !schema.IsUniqueKeys ()) {
2098
2101
THROW_ERROR_EXCEPTION (" \" unique_keys\" cannot be \" false\" for a sorted dynamic table" );
2099
2102
}
2100
2103
@@ -2308,7 +2311,7 @@ void ValidateCumulativeDataWeightColumn(const TTableSchema& schema)
2308
2311
// Validate schema attributes.
2309
2312
void ValidateSchemaAttributes (const TTableSchema& schema)
2310
2313
{
2311
- if (schema.GetUniqueKeys () && schema.GetKeyColumnCount () == 0 ) {
2314
+ if (schema.IsUniqueKeys () && schema.GetKeyColumnCount () == 0 ) {
2312
2315
THROW_ERROR_EXCEPTION (" \" unique_keys\" can only be true if key columns are present" );
2313
2316
}
2314
2317
}
@@ -2325,7 +2328,7 @@ void ValidateTableSchema(
2325
2328
schema.IsSorted (),
2326
2329
isTableDynamic,
2327
2330
options);
2328
- if (!schema.GetStrict () && column.IsRenamed ()) {
2331
+ if (!schema.IsStrict () && column.IsRenamed ()) {
2329
2332
THROW_ERROR_EXCEPTION (" Renamed column %v in non-strict schema" ,
2330
2333
column.GetDiagnosticNameString ());
2331
2334
}
@@ -2396,6 +2399,24 @@ void ValidateNoDescendingSortOrder(const TTableSchema& schema)
2396
2399
}
2397
2400
}
2398
2401
2402
+ void ValidateNoDescendingSortOrder (
2403
+ const std::vector<ESortOrder>& sortOrders,
2404
+ const TKeyColumns& keyColumns)
2405
+ {
2406
+ YT_VERIFY (keyColumns.size () == sortOrders.size ());
2407
+
2408
+ for (int index = 0 ; index < std::ssize (sortOrders); ++index ) {
2409
+ auto sortOrder = sortOrders[index ];
2410
+ const auto & column = keyColumns[index ];
2411
+ if (sortOrder == ESortOrder::Descending) {
2412
+ THROW_ERROR_EXCEPTION (
2413
+ NTableClient::EErrorCode::InvalidSchemaValue,
2414
+ " Descending sort order is not available in this context yet" )
2415
+ << TErrorAttribute (" column_name" , column);
2416
+ }
2417
+ }
2418
+ }
2419
+
2399
2420
void ValidateNoRenamedColumns (const TTableSchema& schema)
2400
2421
{
2401
2422
for (const auto & column : schema.Columns ()) {
@@ -2556,7 +2577,7 @@ size_t THash<NYT::NTableClient::TDeletedColumn>::operator()(const NYT::NTableCli
2556
2577
2557
2578
size_t THash<NYT::NTableClient::TTableSchema>::operator ()(const NYT::NTableClient::TTableSchema& tableSchema) const
2558
2579
{
2559
- size_t result = CombineHashes (THash<bool >()(tableSchema.GetUniqueKeys ()), THash<bool >()(tableSchema.GetStrict ()));
2580
+ size_t result = CombineHashes (THash<bool >()(tableSchema.IsUniqueKeys ()), THash<bool >()(tableSchema.IsStrict ()));
2560
2581
if (tableSchema.HasNontrivialSchemaModification ()) {
2561
2582
result = CombineHashes (
2562
2583
result,
0 commit comments