Skip to content

Commit

Permalink
Rename EOutputFormat -> EDataFormat and AddFormats -> AddOutputFormats (
Browse files Browse the repository at this point in the history
  • Loading branch information
pnv1 authored Sep 5, 2024
1 parent a93d749 commit cba7316
Show file tree
Hide file tree
Showing 24 changed files with 296 additions and 296 deletions.
4 changes: 2 additions & 2 deletions ydb/public/lib/ydb_cli/commands/ydb_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ bool TWorkloadCommandBenchmark::RunBench(TClient& client, NYdbWorkload::IWorkloa
TFsPath(PlanFileName).Parent().MkDirs();
{
TFileOutput out(PlanFileName + ".table");
TQueryPlanPrinter queryPlanPrinter(EOutputFormat::PrettyTable, true, out, 120);
TQueryPlanPrinter queryPlanPrinter(EDataFormat::PrettyTable, true, out, 120);
queryPlanPrinter.Print(res.GetQueryPlan());
}
{
TFileOutput out(PlanFileName + ".json");
TQueryPlanPrinter queryPlanPrinter(EOutputFormat::JsonBase64, true, out, 120);
TQueryPlanPrinter queryPlanPrinter(EDataFormat::JsonBase64, true, out, 120);
queryPlanPrinter.Print(res.GetQueryPlan());
}
{
Expand Down
4 changes: 2 additions & 2 deletions ydb/public/lib/ydb_cli/commands/ydb_service_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void TCommandExportToYt::Config(TConfig& config) {
.NoArgument().StoreTrue(&UseTypeV3);

AddDeprecatedJsonOption(config);
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
config.Opts->MutuallyExclusive("json", "format");
}

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

AddDeprecatedJsonOption(config);
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
config.Opts->MutuallyExclusive("json", "format");
}

Expand Down
8 changes: 4 additions & 4 deletions ydb/public/lib/ydb_cli/commands/ydb_service_import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void TCommandImportFromS3::Config(TConfig& config) {
.RequiredArgument("BOOL").StoreResult<bool>(&UseVirtualAddressing).DefaultValue("true");

AddDeprecatedJsonOption(config);
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
config.Opts->MutuallyExclusive("json", "format");
}

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

AddInputFormats(config, {
EOutputFormat::JsonUnicode,
EOutputFormat::JsonBase64
EDataFormat::JsonUnicode,
EDataFormat::JsonBase64
});
}

Expand Down
8 changes: 4 additions & 4 deletions ydb/public/lib/ydb_cli/commands/ydb_service_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TCommandImportFromCsv : public TCommandImportFileBase {
TCommandImportFromCsv(const TString& cmd = "csv", const TString& cmdDescription = "Import data from CSV file")
: TCommandImportFileBase(cmd, cmdDescription)
{
InputFormat = EOutputFormat::Csv;
InputFormat = EDataFormat::Csv;
Delimiter = ",";
}
void Config(TConfig& config) override;
Expand All @@ -89,7 +89,7 @@ class TCommandImportFromTsv : public TCommandImportFromCsv {
TCommandImportFromTsv()
: TCommandImportFromCsv("tsv", "Import data from TSV file")
{
InputFormat = EOutputFormat::Tsv;
InputFormat = EDataFormat::Tsv;
Delimiter = "\t";
}
};
Expand All @@ -99,7 +99,7 @@ class TCommandImportFromJson : public TCommandImportFileBase {
TCommandImportFromJson()
: TCommandImportFileBase("json", "Import data from JSON file")
{
InputFormat = EOutputFormat::JsonUnicode;
InputFormat = EDataFormat::JsonUnicode;
}
void Config(TConfig& config) override;
void Parse(TConfig& config) override;
Expand All @@ -111,7 +111,7 @@ class TCommandImportFromParquet : public TCommandImportFileBase {
TCommandImportFromParquet(const TString& cmd = "parquet", const TString& cmdDescription = "Import data from Parquet file")
: TCommandImportFileBase(cmd, cmdDescription)
{
InputFormat = EOutputFormat::Parquet;
InputFormat = EDataFormat::Parquet;
}
void Config(TConfig& config) override;
int Run(TConfig& config) override;
Expand Down
32 changes: 16 additions & 16 deletions ydb/public/lib/ydb_cli/commands/ydb_service_monitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void TCommandSelfCheck::Config(TConfig& config) {
TYdbSimpleCommand::Config(config);
config.SetFreeArgsNum(0);

AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::Json });
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::Json });

config.Opts->AddLongOption('v', "verbose", "Return detailed info about components checked with their statuses.")
.StoreTrue(&Verbose);
Expand Down Expand Up @@ -49,8 +49,8 @@ int TCommandSelfCheck::Run(TConfig& config) {
int TCommandSelfCheck::PrintResponse(NMonitoring::TSelfCheckResult& result) {
const auto& proto = NYdb::TProtoAccessor::GetProto(result);
switch (OutputFormat) {
case EOutputFormat::Default:
case EOutputFormat::Pretty:
case EDataFormat::Default:
case EDataFormat::Pretty:
{
NColorizer::TColors colors = NColorizer::AutoColors(Cout);
TStringBuf statusColor;
Expand Down Expand Up @@ -83,22 +83,22 @@ int TCommandSelfCheck::PrintResponse(NMonitoring::TSelfCheckResult& result) {
}
break;
}
case EOutputFormat::Json:
case EDataFormat::Json:
{
TString json;
google::protobuf::util::JsonPrintOptions jsonOpts;
jsonOpts.preserve_proto_field_names = true;
jsonOpts.add_whitespace = true;
auto convertStatus = google::protobuf::util::MessageToJsonString(proto, &json, jsonOpts);
if (convertStatus.ok()) {
Cout << json;
} else {
Cerr << "Error occurred while converting result proto to json" << Endl;
return EXIT_FAILURE;
TString json;
google::protobuf::util::JsonPrintOptions jsonOpts;
jsonOpts.preserve_proto_field_names = true;
jsonOpts.add_whitespace = true;
auto convertStatus = google::protobuf::util::MessageToJsonString(proto, &json, jsonOpts);
if (convertStatus.ok()) {
Cout << json;
} else {
Cerr << "Error occurred while converting result proto to json" << Endl;
return EXIT_FAILURE;
}
break;
}
default:
}
default:
throw TMisuseException() << "This command doesn't support " << OutputFormat << " output format";
}
return EXIT_SUCCESS;
Expand Down
8 changes: 4 additions & 4 deletions ydb/public/lib/ydb_cli/commands/ydb_service_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace NKikimr::NOperationId;
namespace {

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

template <typename T>
void ListOperations(NOperation::TOperationClient& client, ui64 pageSize, const TString& pageToken, EOutputFormat format) {
void ListOperations(NOperation::TOperationClient& client, ui64 pageSize, const TString& pageToken, EDataFormat format) {
NOperation::TOperationsList<T> operations = client.List<T>(pageSize, pageToken).GetValueSync();
ThrowOnError(operations);
PrintOperationsList(operations, format);
Expand Down Expand Up @@ -74,7 +74,7 @@ TCommandGetOperation::TCommandGetOperation()
void TCommandGetOperation::Config(TConfig& config) {
TCommandWithOperationId::Config(config);
AddDeprecatedJsonOption(config);
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::ProtoJsonBase64 });
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::ProtoJsonBase64 });
config.Opts->MutuallyExclusive("json", "format");
}

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

config.SetFreeArgsNum(1);
Expand Down
2 changes: 1 addition & 1 deletion ydb/public/lib/ydb_cli/commands/ydb_service_operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TCommandListOperations : public TYdbCommand,
public TCommandWithFormat {

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

THandler Handler;
bool Hidden;
Expand Down
14 changes: 7 additions & 7 deletions ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void TCommandDescribe::Config(TConfig& config) {
config.Opts->AddLongOption("partition-stats", "[Table|Topic|Consumer] Show partition statistics").StoreTrue(&ShowPartitionStats);

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

config.SetFreeArgsNum(1);
Expand Down Expand Up @@ -940,7 +940,7 @@ int TCommandDescribe::PrintConsumerResponsePretty(const NYdb::NTopic::TConsumerD
}

void TCommandDescribe::WarnAboutTableOptions() {
if (ShowKeyShardBoundaries || ShowStats || ShowPartitionStats || OutputFormat != EOutputFormat::Default) {
if (ShowKeyShardBoundaries || ShowStats || ShowPartitionStats || OutputFormat != EDataFormat::Default) {
TVector<TString> options;
if (ShowKeyShardBoundaries) {
options.emplace_back("\"partition-boundaries\"(\"shard-boundaries\")");
Expand All @@ -951,7 +951,7 @@ void TCommandDescribe::WarnAboutTableOptions() {
if (ShowPartitionStats) {
options.emplace_back("\"partition-stats\"");
}
if (OutputFormat != EOutputFormat::Default) {
if (OutputFormat != EDataFormat::Default) {
options.emplace_back("\"json\"");
}
Cerr << "Note: \"" << Path << "\" is not a table. Option";
Expand Down Expand Up @@ -986,7 +986,7 @@ void TCommandList::Config(TConfig& config) {
.StoreTrue(&FromNewLine);
config.Opts->AddCharOption('m', "Multithread recursive request")
.StoreTrue(&Multithread);
AddFormats(config, { EOutputFormat::Pretty, EOutputFormat::Json });
AddOutputFormats(config, { EDataFormat::Pretty, EDataFormat::Json });
config.SetFreeArgsMax(1);
SetFreeArgTitle(0, "<path>", "Path to list");
}
Expand All @@ -1013,15 +1013,15 @@ int TCommandList::Run(TConfig& config) {
std::unique_ptr<ISchemePrinter> printer;

switch (OutputFormat) {
case EOutputFormat::Default:
case EOutputFormat::Pretty:
case EDataFormat::Default:
case EDataFormat::Pretty:
if (AdvancedMode) {
printer = std::make_unique<TTableSchemePrinter>(driver, std::move(settings));
} else {
printer = std::make_unique<TDefaultSchemePrinter>(driver, std::move(settings));
}
break;
case EOutputFormat::Json:
case EDataFormat::Json:
{
printer = std::make_unique<TJsonSchemePrinter>(driver, std::move(settings), AdvancedMode);
break;
Expand Down
10 changes: 5 additions & 5 deletions ydb/public/lib/ydb_cli/commands/ydb_service_scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ template <typename TCommand, typename TValue>
using TPrettyPrinter = int(TCommand::*)(const TValue&) const;

template <typename TCommand, typename TValue>
static int PrintDescription(TCommand* self, EOutputFormat format, const TValue& value, TPrettyPrinter<TCommand, TValue> prettyFunc) {
static int PrintDescription(TCommand* self, EDataFormat format, const TValue& value, TPrettyPrinter<TCommand, TValue> prettyFunc) {
switch (format) {
case EOutputFormat::Default:
case EOutputFormat::Pretty:
case EDataFormat::Default:
case EDataFormat::Pretty:
return std::invoke(prettyFunc, self, value);
case EOutputFormat::Json:
case EDataFormat::Json:
Cerr << "Warning! Option --json is deprecated and will be removed soon. "
<< "Use \"--format proto-json-base64\" option instead." << Endl;
[[fallthrough]];
case EOutputFormat::ProtoJsonBase64:
case EDataFormat::ProtoJsonBase64:
return PrintProtoJsonBase64(TProtoAccessor::GetProto(value));
default:
throw TMisuseException() << "This command doesn't support " << format << " output format";
Expand Down
32 changes: 16 additions & 16 deletions ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ void TCommandExecuteYqlScript::Config(TConfig& config) {
config.Opts->AddLongOption("explain", "Explain query").Optional().StoreTrue(&Explain);
config.Opts->AddLongOption("show-response-metadata", ResponseHeadersHelp).Optional().StoreTrue(&ShowHeaders);

AddFormats(config, {
EOutputFormat::Pretty,
EOutputFormat::JsonUnicode,
EOutputFormat::JsonUnicodeArray,
EOutputFormat::JsonBase64,
EOutputFormat::JsonBase64Array,
EOutputFormat::Parquet,
AddOutputFormats(config, {
EDataFormat::Pretty,
EDataFormat::JsonUnicode,
EDataFormat::JsonUnicodeArray,
EDataFormat::JsonBase64,
EDataFormat::JsonBase64Array,
EDataFormat::Parquet,
});

AddParametersOption(config);

AddInputFormats(config, {
EOutputFormat::JsonUnicode,
EOutputFormat::JsonBase64
EDataFormat::JsonUnicode,
EDataFormat::JsonBase64
});

AddStdinFormats(config, {
EOutputFormat::JsonUnicode,
EOutputFormat::JsonBase64,
EOutputFormat::Raw,
EOutputFormat::Csv,
EOutputFormat::Tsv
EDataFormat::JsonUnicode,
EDataFormat::JsonBase64,
EDataFormat::Raw,
EDataFormat::Csv,
EDataFormat::Tsv
}, {
EOutputFormat::NoFraming,
EOutputFormat::NewlineDelimited
EDataFormat::NoFraming,
EDataFormat::NewlineDelimited
});

AddParametersStdinOption(config, "script");
Expand Down
Loading

0 comments on commit cba7316

Please sign in to comment.