Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-gogov committed Dec 20, 2024
1 parent 5c721ab commit c34b4b8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ydb/core/config/validation/column_shard_config_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ EValidationResult ValidateDefaultCompression(const NKikimrConfig::TColumnShardCo
if (!columnShardConfig.HasDefaultCompression() && !columnShardConfig.HasDefaultCompressionLevel()) {
return EValidationResult::Ok;
}
if (!columnShardConfig.HasDefaultCompression() && columnShardConfig.HasDefaultCompressionLevel()) {
msg.push_back("ColumnShardConfig: compression level is set without compression type");
return EValidationResult::Error;
}
std::optional<arrow::Compression::type> codec = NArrow::CompressionFromProto(columnShardConfig.GetDefaultCompression());
if (!codec.has_value()) {
msg.push_back("ColumnShardConfig: Unknown compression");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ Y_UNIT_TEST_SUITE(ColumnShardConfigValidation) {
UNIT_ASSERT_C(error.empty(), "Should not be errors");
}

Y_UNIT_TEST(NotAcceptDefaultCompression) {
NKikimrConfig::TColumnShardConfig CSConfig;
std::vector<TString> error;
CSConfig.SetDefaultCompressionLevel(2);
EValidationResult result = ValidateColumnShardConfig(CSConfig, error);
UNIT_ASSERT_EQUAL(result, EValidationResult::Error);
UNIT_ASSERT_VALUES_EQUAL(error.size(), 1);
UNIT_ASSERT_STRINGS_EQUAL(error.front(), "ColumnShardConfig: compression level is set without compression type");
}

Y_UNIT_TEST(CorrectPlainCompression) {
NKikimrConfig::TColumnShardConfig CSConfig;
std::vector<TString> error;
Expand Down
19 changes: 14 additions & 5 deletions ydb/core/formats/arrow/serializer/native.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,23 @@ class TNativeSerializer: public ISerializer {
virtual TConclusionStatus DoDeserializeFromRequest(NYql::TFeaturesExtractor& features) override;

static arrow::Compression::type GetDefaultCompressionType() {
return CompressionFromProto(AppData()->ColumnShardConfig.GetDefaultCompression()).value();
if (!HasAppData() && !AppDataVerified().ColumnShardConfig.HasDefaultCompression()) {
return arrow::Compression::ZSTD;
}
return CompressionFromProto(AppDataVerified().ColumnShardConfig.GetDefaultCompression()).value();
}

static std::shared_ptr<arrow::util::Codec> GetDefaultCodec() {
if (!HasAppData() || (!AppDataVerified().ColumnShardConfig.HasDefaultCompression() &&
!AppDataVerified().ColumnShardConfig.HasDefaultCompressionLevel())) {
return NArrow::TStatusValidator::GetValid(arrow::util::Codec::Create(arrow::Compression::type::ZSTD, 1));
}
arrow::Compression::type codec = GetDefaultCompressionType();
if (codec == arrow::Compression::type::ZSTD) {
i32 codecLevel = AppData()->ColumnShardConfig.GetDefaultCompressionLevel();
return NArrow::TStatusValidator::GetValid(arrow::util::Codec::Create(codec, codecLevel));
if (AppDataVerified().ColumnShardConfig.HasDefaultCompressionLevel()) {
return NArrow::TStatusValidator::GetValid(
arrow::util::Codec::Create(codec, AppDataVerified().ColumnShardConfig.GetDefaultCompressionLevel()));
} else if (codec == arrow::Compression::ZSTD) {
return NArrow::TStatusValidator::GetValid(arrow::util::Codec::Create(codec, 1));
}
return NArrow::TStatusValidator::GetValid(arrow::util::Codec::Create(codec));
}
Expand Down Expand Up @@ -99,7 +108,7 @@ class TNativeSerializer: public ISerializer {
}

static arrow::ipc::IpcOptions GetDefaultOptions() {
static arrow::ipc::IpcWriteOptions options = BuildDefaultOptions();
arrow::ipc::IpcWriteOptions options = BuildDefaultOptions();
return options;
}

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/kqp/ut/olap/sys_view_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(KqpOlapSysView) {
auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<NOlap::TWaitCompactionController>();
NKikimrConfig::TAppConfig appConfig;
auto* CSConfig = appConfig.MutableColumnShardConfig();
CSConfig->SetDefaultCompression(NKikimrSchemeOp::EColumnCodec::ColumnCodecPlain);
CSConfig->SetDefaultCompression(NKikimrSchemeOp::EColumnCodec::ColumnCodecLZ4);
auto settings = TKikimrSettings().SetWithSampleTables(false).SetAppConfig(appConfig);
TKikimrRunner kikimr(settings);
Tests::NCommon::TLoggerInit(kikimr).Initialize();
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1738,8 +1738,8 @@ message TColumnShardConfig {
optional bool AllowNullableColumnsInPK = 29 [default = false];
optional uint32 RestoreDataOnWriteTimeoutSeconds = 30;
optional bool UseSlicesFilter = 31 [default = true];
optional NKikimrSchemeOp.EColumnCodec DefaultCompression = 32 [default = ColumnCodecZSTD];
optional int32 DefaultCompressionLevel = 33 [default = 1];
optional NKikimrSchemeOp.EColumnCodec DefaultCompression = 32;
optional int32 DefaultCompressionLevel = 33;
}

message TSchemeShardConfig {
Expand Down

0 comments on commit c34b4b8

Please sign in to comment.