Skip to content

Commit cba7316

Browse files
authored
Rename EOutputFormat -> EDataFormat and AddFormats -> AddOutputFormats (#8803)
1 parent a93d749 commit cba7316

24 files changed

+296
-296
lines changed

ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ bool TWorkloadCommandBenchmark::RunBench(TClient& client, NYdbWorkload::IWorkloa
375375
TFsPath(PlanFileName).Parent().MkDirs();
376376
{
377377
TFileOutput out(PlanFileName + ".table");
378-
TQueryPlanPrinter queryPlanPrinter(EOutputFormat::PrettyTable, true, out, 120);
378+
TQueryPlanPrinter queryPlanPrinter(EDataFormat::PrettyTable, true, out, 120);
379379
queryPlanPrinter.Print(res.GetQueryPlan());
380380
}
381381
{
382382
TFileOutput out(PlanFileName + ".json");
383-
TQueryPlanPrinter queryPlanPrinter(EOutputFormat::JsonBase64, true, out, 120);
383+
TQueryPlanPrinter queryPlanPrinter(EDataFormat::JsonBase64, true, out, 120);
384384
queryPlanPrinter.Print(res.GetQueryPlan());
385385
}
386386
{

ydb/public/lib/ydb_cli/commands/ydb_service_export.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void TCommandExportToYt::Config(TConfig& config) {
132132
.NoArgument().StoreTrue(&UseTypeV3);
133133

134134
AddDeprecatedJsonOption(config);
135-
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
135+
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
136136
config.Opts->MutuallyExclusive("json", "format");
137137
}
138138

@@ -281,7 +281,7 @@ void TCommandExportToS3::Config(TConfig& config) {
281281
.RequiredArgument("BOOL").StoreResult<bool>(&UseVirtualAddressing).DefaultValue("true");
282282

283283
AddDeprecatedJsonOption(config);
284-
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
284+
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
285285
config.Opts->MutuallyExclusive("json", "format");
286286
}
287287

ydb/public/lib/ydb_cli/commands/ydb_service_import.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void TCommandImportFromS3::Config(TConfig& config) {
9696
.RequiredArgument("BOOL").StoreResult<bool>(&UseVirtualAddressing).DefaultValue("true");
9797

9898
AddDeprecatedJsonOption(config);
99-
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
99+
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
100100
config.Opts->MutuallyExclusive("json", "format");
101101
}
102102

@@ -265,7 +265,7 @@ void TCommandImportFromCsv::Config(TConfig& config) {
265265
config.Opts->AddLongOption("newline-delimited",
266266
"No newline characters inside records, enables some import optimizations (see docs)")
267267
.StoreTrue(&NewlineDelimited);
268-
if (InputFormat == EOutputFormat::Csv) {
268+
if (InputFormat == EDataFormat::Csv) {
269269
config.Opts->AddLongOption("delimiter", "Field delimiter in rows")
270270
.RequiredArgument("STRING").StoreResult(&Delimiter).DefaultValue(Delimiter);
271271
}
@@ -308,8 +308,8 @@ void TCommandImportFromJson::Config(TConfig& config) {
308308
TCommandImportFileBase::Config(config);
309309

310310
AddInputFormats(config, {
311-
EOutputFormat::JsonUnicode,
312-
EOutputFormat::JsonBase64
311+
EDataFormat::JsonUnicode,
312+
EDataFormat::JsonBase64
313313
});
314314
}
315315

ydb/public/lib/ydb_cli/commands/ydb_service_import.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class TCommandImportFromCsv : public TCommandImportFileBase {
6969
TCommandImportFromCsv(const TString& cmd = "csv", const TString& cmdDescription = "Import data from CSV file")
7070
: TCommandImportFileBase(cmd, cmdDescription)
7171
{
72-
InputFormat = EOutputFormat::Csv;
72+
InputFormat = EDataFormat::Csv;
7373
Delimiter = ",";
7474
}
7575
void Config(TConfig& config) override;
@@ -89,7 +89,7 @@ class TCommandImportFromTsv : public TCommandImportFromCsv {
8989
TCommandImportFromTsv()
9090
: TCommandImportFromCsv("tsv", "Import data from TSV file")
9191
{
92-
InputFormat = EOutputFormat::Tsv;
92+
InputFormat = EDataFormat::Tsv;
9393
Delimiter = "\t";
9494
}
9595
};
@@ -99,7 +99,7 @@ class TCommandImportFromJson : public TCommandImportFileBase {
9999
TCommandImportFromJson()
100100
: TCommandImportFileBase("json", "Import data from JSON file")
101101
{
102-
InputFormat = EOutputFormat::JsonUnicode;
102+
InputFormat = EDataFormat::JsonUnicode;
103103
}
104104
void Config(TConfig& config) override;
105105
void Parse(TConfig& config) override;
@@ -111,7 +111,7 @@ class TCommandImportFromParquet : public TCommandImportFileBase {
111111
TCommandImportFromParquet(const TString& cmd = "parquet", const TString& cmdDescription = "Import data from Parquet file")
112112
: TCommandImportFileBase(cmd, cmdDescription)
113113
{
114-
InputFormat = EOutputFormat::Parquet;
114+
InputFormat = EDataFormat::Parquet;
115115
}
116116
void Config(TConfig& config) override;
117117
int Run(TConfig& config) override;

ydb/public/lib/ydb_cli/commands/ydb_service_monitoring.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void TCommandSelfCheck::Config(TConfig& config) {
2020
TYdbSimpleCommand::Config(config);
2121
config.SetFreeArgsNum(0);
2222

23-
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::Json });
23+
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::Json });
2424

2525
config.Opts->AddLongOption('v', "verbose", "Return detailed info about components checked with their statuses.")
2626
.StoreTrue(&Verbose);
@@ -49,8 +49,8 @@ int TCommandSelfCheck::Run(TConfig& config) {
4949
int TCommandSelfCheck::PrintResponse(NMonitoring::TSelfCheckResult& result) {
5050
const auto& proto = NYdb::TProtoAccessor::GetProto(result);
5151
switch (OutputFormat) {
52-
case EOutputFormat::Default:
53-
case EOutputFormat::Pretty:
52+
case EDataFormat::Default:
53+
case EDataFormat::Pretty:
5454
{
5555
NColorizer::TColors colors = NColorizer::AutoColors(Cout);
5656
TStringBuf statusColor;
@@ -83,22 +83,22 @@ int TCommandSelfCheck::PrintResponse(NMonitoring::TSelfCheckResult& result) {
8383
}
8484
break;
8585
}
86-
case EOutputFormat::Json:
86+
case EDataFormat::Json:
8787
{
88-
TString json;
89-
google::protobuf::util::JsonPrintOptions jsonOpts;
90-
jsonOpts.preserve_proto_field_names = true;
91-
jsonOpts.add_whitespace = true;
92-
auto convertStatus = google::protobuf::util::MessageToJsonString(proto, &json, jsonOpts);
93-
if (convertStatus.ok()) {
94-
Cout << json;
95-
} else {
96-
Cerr << "Error occurred while converting result proto to json" << Endl;
97-
return EXIT_FAILURE;
88+
TString json;
89+
google::protobuf::util::JsonPrintOptions jsonOpts;
90+
jsonOpts.preserve_proto_field_names = true;
91+
jsonOpts.add_whitespace = true;
92+
auto convertStatus = google::protobuf::util::MessageToJsonString(proto, &json, jsonOpts);
93+
if (convertStatus.ok()) {
94+
Cout << json;
95+
} else {
96+
Cerr << "Error occurred while converting result proto to json" << Endl;
97+
return EXIT_FAILURE;
9898
}
9999
break;
100-
}
101-
default:
100+
}
101+
default:
102102
throw TMisuseException() << "This command doesn't support " << OutputFormat << " output format";
103103
}
104104
return EXIT_SUCCESS;

ydb/public/lib/ydb_cli/commands/ydb_service_operation.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using namespace NKikimr::NOperationId;
1616
namespace {
1717

1818
template <typename T>
19-
int GetOperation(NOperation::TOperationClient& client, const TOperationId& id, EOutputFormat format) {
19+
int GetOperation(NOperation::TOperationClient& client, const TOperationId& id, EDataFormat format) {
2020
T operation = client.Get<T>(id).GetValueSync();
2121
switch (operation.Status().GetStatus()) {
2222
case EStatus::SUCCESS:
@@ -32,7 +32,7 @@ namespace {
3232
}
3333

3434
template <typename T>
35-
void ListOperations(NOperation::TOperationClient& client, ui64 pageSize, const TString& pageToken, EOutputFormat format) {
35+
void ListOperations(NOperation::TOperationClient& client, ui64 pageSize, const TString& pageToken, EDataFormat format) {
3636
NOperation::TOperationsList<T> operations = client.List<T>(pageSize, pageToken).GetValueSync();
3737
ThrowOnError(operations);
3838
PrintOperationsList(operations, format);
@@ -74,7 +74,7 @@ TCommandGetOperation::TCommandGetOperation()
7474
void TCommandGetOperation::Config(TConfig& config) {
7575
TCommandWithOperationId::Config(config);
7676
AddDeprecatedJsonOption(config);
77-
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
77+
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
7878
config.Opts->MutuallyExclusive("json", "format");
7979
}
8080

@@ -178,7 +178,7 @@ void TCommandListOperations::Config(TConfig& config) {
178178
config.Opts->AddLongOption('t', "page-token", "Page token")
179179
.RequiredArgument("STRING").StoreResult(&PageToken);
180180
AddDeprecatedJsonOption(config);
181-
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
181+
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
182182
config.Opts->MutuallyExclusive("json", "format");
183183

184184
config.SetFreeArgsNum(1);

ydb/public/lib/ydb_cli/commands/ydb_service_operation.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class TCommandListOperations : public TYdbCommand,
5252
public TCommandWithFormat {
5353

5454
struct THandlerWrapper {
55-
using THandler = std::function<void(NOperation::TOperationClient&, ui64, const TString&, EOutputFormat)>;
55+
using THandler = std::function<void(NOperation::TOperationClient&, ui64, const TString&, EDataFormat)>;
5656

5757
THandler Handler;
5858
bool Hidden;

ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void TCommandDescribe::Config(TConfig& config) {
223223
config.Opts->AddLongOption("partition-stats", "[Table|Topic|Consumer] Show partition statistics").StoreTrue(&ShowPartitionStats);
224224

225225
AddDeprecatedJsonOption(config, "(Deprecated, will be removed soon. Use --format option instead) [Table] Output in json format");
226-
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
226+
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
227227
config.Opts->MutuallyExclusive("json", "format");
228228

229229
config.SetFreeArgsNum(1);
@@ -940,7 +940,7 @@ int TCommandDescribe::PrintConsumerResponsePretty(const NYdb::NTopic::TConsumerD
940940
}
941941

942942
void TCommandDescribe::WarnAboutTableOptions() {
943-
if (ShowKeyShardBoundaries || ShowStats || ShowPartitionStats || OutputFormat != EOutputFormat::Default) {
943+
if (ShowKeyShardBoundaries || ShowStats || ShowPartitionStats || OutputFormat != EDataFormat::Default) {
944944
TVector<TString> options;
945945
if (ShowKeyShardBoundaries) {
946946
options.emplace_back("\"partition-boundaries\"(\"shard-boundaries\")");
@@ -951,7 +951,7 @@ void TCommandDescribe::WarnAboutTableOptions() {
951951
if (ShowPartitionStats) {
952952
options.emplace_back("\"partition-stats\"");
953953
}
954-
if (OutputFormat != EOutputFormat::Default) {
954+
if (OutputFormat != EDataFormat::Default) {
955955
options.emplace_back("\"json\"");
956956
}
957957
Cerr << "Note: \"" << Path << "\" is not a table. Option";
@@ -986,7 +986,7 @@ void TCommandList::Config(TConfig& config) {
986986
.StoreTrue(&FromNewLine);
987987
config.Opts->AddCharOption('m', "Multithread recursive request")
988988
.StoreTrue(&Multithread);
989-
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::Json });
989+
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::Json });
990990
config.SetFreeArgsMax(1);
991991
SetFreeArgTitle(0, "<path>", "Path to list");
992992
}
@@ -1013,15 +1013,15 @@ int TCommandList::Run(TConfig& config) {
10131013
std::unique_ptr<ISchemePrinter> printer;
10141014

10151015
switch (OutputFormat) {
1016-
case EOutputFormat::Default:
1017-
case EOutputFormat::Pretty:
1016+
case EDataFormat::Default:
1017+
case EDataFormat::Pretty:
10181018
if (AdvancedMode) {
10191019
printer = std::make_unique<TTableSchemePrinter>(driver, std::move(settings));
10201020
} else {
10211021
printer = std::make_unique<TDefaultSchemePrinter>(driver, std::move(settings));
10221022
}
10231023
break;
1024-
case EOutputFormat::Json:
1024+
case EDataFormat::Json:
10251025
{
10261026
printer = std::make_unique<TJsonSchemePrinter>(driver, std::move(settings), AdvancedMode);
10271027
break;

ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ template <typename TCommand, typename TValue>
5858
using TPrettyPrinter = int(TCommand::*)(const TValue&) const;
5959

6060
template <typename TCommand, typename TValue>
61-
static int PrintDescription(TCommand* self, EOutputFormat format, const TValue& value, TPrettyPrinter<TCommand, TValue> prettyFunc) {
61+
static int PrintDescription(TCommand* self, EDataFormat format, const TValue& value, TPrettyPrinter<TCommand, TValue> prettyFunc) {
6262
switch (format) {
63-
case EOutputFormat::Default:
64-
case EOutputFormat::Pretty:
63+
case EDataFormat::Default:
64+
case EDataFormat::Pretty:
6565
return std::invoke(prettyFunc, self, value);
66-
case EOutputFormat::Json:
66+
case EDataFormat::Json:
6767
Cerr << "Warning! Option --json is deprecated and will be removed soon. "
6868
<< "Use \"--format proto-json-base64\" option instead." << Endl;
6969
[[fallthrough]];
70-
case EOutputFormat::ProtoJsonBase64:
70+
case EDataFormat::ProtoJsonBase64:
7171
return PrintProtoJsonBase64(TProtoAccessor::GetProto(value));
7272
default:
7373
throw TMisuseException() << "This command doesn't support " << format << " output format";

ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ void TCommandExecuteYqlScript::Config(TConfig& config) {
3333
config.Opts->AddLongOption("explain", "Explain query").Optional().StoreTrue(&Explain);
3434
config.Opts->AddLongOption("show-response-metadata", ResponseHeadersHelp).Optional().StoreTrue(&ShowHeaders);
3535

36-
AddFormats(config, {
37-
EOutputFormat::Pretty,
38-
EOutputFormat::JsonUnicode,
39-
EOutputFormat::JsonUnicodeArray,
40-
EOutputFormat::JsonBase64,
41-
EOutputFormat::JsonBase64Array,
42-
EOutputFormat::Parquet,
36+
AddOutputFormats(config, {
37+
EDataFormat::Pretty,
38+
EDataFormat::JsonUnicode,
39+
EDataFormat::JsonUnicodeArray,
40+
EDataFormat::JsonBase64,
41+
EDataFormat::JsonBase64Array,
42+
EDataFormat::Parquet,
4343
});
4444

4545
AddParametersOption(config);
4646

4747
AddInputFormats(config, {
48-
EOutputFormat::JsonUnicode,
49-
EOutputFormat::JsonBase64
48+
EDataFormat::JsonUnicode,
49+
EDataFormat::JsonBase64
5050
});
5151

5252
AddStdinFormats(config, {
53-
EOutputFormat::JsonUnicode,
54-
EOutputFormat::JsonBase64,
55-
EOutputFormat::Raw,
56-
EOutputFormat::Csv,
57-
EOutputFormat::Tsv
53+
EDataFormat::JsonUnicode,
54+
EDataFormat::JsonBase64,
55+
EDataFormat::Raw,
56+
EDataFormat::Csv,
57+
EDataFormat::Tsv
5858
}, {
59-
EOutputFormat::NoFraming,
60-
EOutputFormat::NewlineDelimited
59+
EDataFormat::NoFraming,
60+
EDataFormat::NewlineDelimited
6161
});
6262

6363
AddParametersStdinOption(config, "script");

0 commit comments

Comments
 (0)