Skip to content

Commit d41a790

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to a8206a211f
1 parent a79c7e4 commit d41a790

42 files changed

Lines changed: 857 additions & 381 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/duckdb/extension/parquet/parquet_multi_file_info.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ static void BindSchema(ClientContext &context, vector<LogicalType> &return_types
105105
#endif
106106

107107
res.default_expression = make_uniq<ConstantExpression>(column.default_value);
108-
reader_bind.schema.emplace_back(std::move(res));
108+
reader_bind.schema.emplace_back(res);
109109
}
110110
ParseFileRowNumberOption(reader_bind, options, return_types, names);
111111
if (options.file_row_number) {
112112
MultiFileColumnDefinition res("file_row_number", LogicalType::BIGINT);
113113
res.identifier = Value::INTEGER(MultiFileReader::ORDINAL_FIELD_ID);
114114
schema_col_names.push_back(res.name);
115115
schema_col_types.push_back(res.type);
116-
reader_bind.schema.emplace_back(std::move(res));
116+
reader_bind.schema.emplace_back(res);
117117
}
118118

119119
if (match_by_field_id) {

src/duckdb/src/common/box_renderer.cpp

Lines changed: 81 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -902,19 +902,11 @@ void BoxRenderer::RenderValues(const list<ColumnDataCollection> &collections, co
902902
}
903903
}
904904

905-
void BoxRenderer::RenderRowCount(string row_count_str, string shown_str, const string &column_count_str,
906-
const vector<idx_t> &boundaries, bool has_hidden_rows, bool has_hidden_columns,
907-
idx_t total_length, idx_t row_count, idx_t column_count, idx_t minimum_row_length,
908-
BaseResultRenderer &ss) {
909-
// check if we can merge the row_count_str and the shown_str
910-
bool display_shown_separately = has_hidden_rows;
911-
if (has_hidden_rows && total_length >= row_count_str.size() + shown_str.size() + 5) {
912-
// we can!
913-
row_count_str += " " + shown_str;
914-
shown_str = string();
915-
display_shown_separately = false;
916-
minimum_row_length = row_count_str.size() + 4;
917-
}
905+
void BoxRenderer::RenderRowCount(string &row_count_str, string &readable_rows_str, string &shown_str,
906+
const string &column_count_str, const vector<idx_t> &boundaries, bool has_hidden_rows,
907+
bool has_hidden_columns, idx_t total_length, idx_t row_count, idx_t column_count,
908+
idx_t minimum_row_length, BaseResultRenderer &ss) {
909+
// check if we can merge the row_count_str, readable_rows_str and the shown_str
918910
auto minimum_length = row_count_str.size() + column_count_str.size() + 6;
919911
bool render_rows_and_columns = total_length >= minimum_length &&
920912
((has_hidden_columns && row_count > 0) || (row_count >= 10 && column_count > 1));
@@ -941,23 +933,75 @@ void BoxRenderer::RenderRowCount(string row_count_str, string shown_str, const s
941933
if (!render_anything) {
942934
return;
943935
}
936+
idx_t padding = total_length - row_count_str.size() - 4;
937+
if (render_rows_and_columns) {
938+
padding -= column_count_str.size();
939+
}
940+
string extra_render_str;
941+
// do we have to space to render the minimum_row_length and the shown string on the same row?
942+
idx_t shown_size = readable_rows_str.size() + shown_str.size() + (readable_rows_str.empty() ? 3 : 5);
943+
if (has_hidden_rows && padding >= shown_size) {
944+
// we have space - render it here
945+
extra_render_str = " (";
946+
if (!readable_rows_str.empty()) {
947+
extra_render_str += readable_rows_str + ", ";
948+
}
949+
extra_render_str += shown_str;
950+
extra_render_str += ")";
951+
D_ASSERT(extra_render_str.size() == shown_size);
952+
padding -= shown_size;
953+
readable_rows_str = string();
954+
shown_str = string();
955+
}
944956

957+
ss << config.VERTICAL;
958+
ss << " ";
945959
if (render_rows_and_columns) {
946-
ss << config.VERTICAL;
947-
ss << " ";
948960
ss.Render(ResultRenderType::FOOTER, row_count_str);
949-
ss << string(total_length - row_count_str.size() - column_count_str.size() - 4, ' ');
961+
if (!extra_render_str.empty()) {
962+
ss.Render(ResultRenderType::NULL_VALUE, extra_render_str);
963+
}
964+
ss << string(padding, ' ');
950965
ss.Render(ResultRenderType::FOOTER, column_count_str);
951-
ss << " ";
952-
ss << config.VERTICAL;
953-
ss << '\n';
954966
} else if (render_rows) {
955-
RenderValue(ss, row_count_str, total_length - 4, ResultRenderType::FOOTER);
956-
ss << config.VERTICAL;
957-
ss << '\n';
958-
959-
if (display_shown_separately) {
960-
RenderValue(ss, shown_str, total_length - 4, ResultRenderType::FOOTER);
967+
idx_t lpadding = padding / 2;
968+
idx_t rpadding = padding - lpadding;
969+
ss << string(lpadding, ' ');
970+
ss.Render(ResultRenderType::FOOTER, row_count_str);
971+
if (!extra_render_str.empty()) {
972+
ss.Render(ResultRenderType::NULL_VALUE, extra_render_str);
973+
}
974+
ss << string(rpadding, ' ');
975+
}
976+
ss << " ";
977+
ss << config.VERTICAL;
978+
ss << '\n';
979+
if (!readable_rows_str.empty() || !shown_str.empty()) {
980+
// we still need to render the readable rows/shown strings
981+
// check if we can merge the two onto one row
982+
idx_t combined_shown_length = readable_rows_str.size() + shown_str.size() + 4;
983+
if (combined_shown_length <= total_length) {
984+
// we can! merge them
985+
ss << config.VERTICAL;
986+
ss << " ";
987+
ss.Render(ResultRenderType::NULL_VALUE, readable_rows_str);
988+
ss << string(total_length - combined_shown_length, ' ');
989+
ss.Render(ResultRenderType::NULL_VALUE, shown_str);
990+
ss << " ";
991+
ss << config.VERTICAL;
992+
ss << '\n';
993+
readable_rows_str = string();
994+
shown_str = string();
995+
}
996+
ValueRenderAlignment alignment =
997+
render_rows_and_columns ? ValueRenderAlignment::LEFT : ValueRenderAlignment::MIDDLE;
998+
if (!readable_rows_str.empty()) {
999+
RenderValue(ss, "(" + readable_rows_str + ")", total_length - 4, ResultRenderType::NULL_VALUE, alignment);
1000+
ss << config.VERTICAL;
1001+
ss << '\n';
1002+
}
1003+
if (!shown_str.empty()) {
1004+
RenderValue(ss, "(" + shown_str + ")", total_length - 4, ResultRenderType::NULL_VALUE, alignment);
9611005
ss << config.VERTICAL;
9621006
ss << '\n';
9631007
}
@@ -1011,16 +1055,23 @@ void BoxRenderer::Render(ClientContext &context, const vector<string> &names, co
10111055
if (has_limited_rows) {
10121056
row_count_str = "? rows";
10131057
}
1058+
string readable_rows_str;
1059+
if (config.large_number_rendering == LargeNumberRendering::FOOTER && !has_limited_rows) {
1060+
readable_rows_str = TryFormatLargeNumber(to_string(row_count));
1061+
if (!readable_rows_str.empty()) {
1062+
readable_rows_str += " rows";
1063+
}
1064+
}
10141065
string shown_str;
10151066
bool has_hidden_rows = top_rows < row_count;
10161067
if (has_hidden_rows) {
1017-
shown_str = "(";
10181068
if (has_limited_rows) {
10191069
shown_str += ">" + FormatNumber(to_string(config.limit - 1)) + " rows, ";
10201070
}
1021-
shown_str += FormatNumber(to_string(top_rows + bottom_rows)) + " shown)";
1071+
shown_str += FormatNumber(to_string(top_rows + bottom_rows)) + " shown";
10221072
}
1023-
auto minimum_row_length = MaxValue<idx_t>(row_count_str.size(), shown_str.size()) + 4;
1073+
auto minimum_row_length =
1074+
MaxValue<idx_t>(MaxValue<idx_t>(row_count_str.size(), shown_str.size() + 2), readable_rows_str.size() + 2) + 4;
10241075

10251076
// fetch the top and bottom render collections from the result
10261077
auto collections = FetchRenderCollections(context, result, top_rows, bottom_rows);
@@ -1073,7 +1124,7 @@ void BoxRenderer::Render(ClientContext &context, const vector<string> &names, co
10731124
if (config.render_mode == RenderMode::COLUMNS) {
10741125
if (has_hidden_columns) {
10751126
has_hidden_rows = true;
1076-
shown_str = " (" + to_string(column_count - 3) + " shown)";
1127+
shown_str = to_string(column_count - 3) + " shown";
10771128
} else {
10781129
shown_str = string();
10791130
}
@@ -1084,7 +1135,7 @@ void BoxRenderer::Render(ClientContext &context, const vector<string> &names, co
10841135
}
10851136
}
10861137

1087-
RenderRowCount(std::move(row_count_str), std::move(shown_str), column_count_str, boundaries, has_hidden_rows,
1138+
RenderRowCount(row_count_str, readable_rows_str, shown_str, column_count_str, boundaries, has_hidden_rows,
10881139
has_hidden_columns, total_length, row_count, column_count, minimum_row_length, ss);
10891140
}
10901141

src/duckdb/src/common/progress_bar/progress_bar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ void ProgressBar::Update(bool final) {
133133
if (final) {
134134
FinishProgressBarPrint();
135135
} else {
136-
PrintProgress(LossyNumericCast<int>(query_progress.percentage.load()));
136+
PrintProgress(query_progress.percentage.load());
137137
}
138138
}
139139
}
140140

141-
void ProgressBar::PrintProgress(int current_percentage_p) {
141+
void ProgressBar::PrintProgress(double current_percentage_p) {
142142
D_ASSERT(display);
143143
display->Update(current_percentage_p);
144144
}

src/duckdb/src/common/progress_bar/terminal_progress_bar_display.cpp

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,65 @@ int32_t TerminalProgressBarDisplay::NormalizePercentage(double percentage) {
1414
return int32_t(percentage);
1515
}
1616

17-
void TerminalProgressBarDisplay::PrintProgressInternal(int32_t percentage) {
17+
static string FormatETA(double seconds, bool elapsed = false) {
18+
// for terminal rendering purposes, we need to make sure the length is always the same
19+
// we pad the end with spaces if that is not the case
20+
// the maximum length here is "(~10.35 minutes remaining)" (26 bytes)
21+
// always pad to this amount
22+
static constexpr idx_t RENDER_SIZE = 26;
23+
// Desired formats:
24+
// 00:00:00.00 remaining
25+
// unknown remaining
26+
// 00:00:00.00 elapsed
27+
if (!elapsed && seconds > 3600 * 99) {
28+
// estimate larger than 99 hours remaining
29+
string result = "(>99 hours remaining)";
30+
result += string(RENDER_SIZE - result.size(), ' ');
31+
return result;
32+
}
33+
if (seconds < 0) {
34+
// Invalid or unknown ETA, skip rendering estimate
35+
return string(RENDER_SIZE, ' ');
36+
}
37+
38+
// Round to nearest centisecond as integer
39+
auto total_centiseconds = static_cast<uint64_t>(std::llround(seconds * 100.0));
40+
41+
// Split into seconds and centiseconds
42+
uint64_t total_seconds = total_centiseconds / 100;
43+
uint32_t centiseconds = static_cast<uint32_t>(total_centiseconds % 100);
44+
45+
// Break down total_seconds
46+
uint64_t hours = total_seconds / 3600;
47+
uint32_t minutes = static_cast<uint32_t>((total_seconds % 3600) / 60);
48+
uint32_t secs = static_cast<uint32_t>(total_seconds % 60);
49+
string result;
50+
result = "(";
51+
if (!elapsed) {
52+
if (hours == 0 && minutes == 0 && secs == 0) {
53+
result += StringUtil::Format("<1 second");
54+
} else if (hours == 0 && minutes == 0) {
55+
result += StringUtil::Format("~%u second%s", secs, secs > 1 ? "s" : "");
56+
} else if (hours == 0) {
57+
auto minute_fraction = static_cast<uint32_t>(static_cast<double>(secs) / 60.0 * 10);
58+
result += StringUtil::Format("~%u.%u minutes", minutes, minute_fraction);
59+
} else {
60+
auto hour_fraction = static_cast<uint32_t>(static_cast<double>(minutes) / 60.0 * 10);
61+
result += StringUtil::Format("~%llu.%u hours", hours, hour_fraction);
62+
}
63+
result += " remaining";
64+
} else {
65+
result += StringUtil::Format("%02llu:%02u:%02u.%02llu", hours, minutes, secs, centiseconds);
66+
result += " elapsed";
67+
}
68+
result += ")";
69+
if (result.size() < RENDER_SIZE) {
70+
result += string(RENDER_SIZE - result.size(), ' ');
71+
}
72+
return result;
73+
}
74+
75+
void TerminalProgressBarDisplay::PrintProgressInternal(int32_t percentage, double seconds, bool finished) {
1876
string result;
1977
// we divide the number of blocks by the percentage
2078
// 0% = 0
@@ -52,22 +110,26 @@ void TerminalProgressBarDisplay::PrintProgressInternal(int32_t percentage) {
52110
}
53111
result += PROGRESS_END;
54112
result += " ";
113+
result += FormatETA(seconds, finished);
55114

56115
Printer::RawPrint(OutputStream::STREAM_STDOUT, result);
57116
}
58117

59118
void TerminalProgressBarDisplay::Update(double percentage) {
119+
const double current_time = GetElapsedDuration();
120+
121+
// Filters go from 0 to 1, percentage is from 0-100
122+
const double filter_percentage = percentage / 100.0;
123+
ukf.Update(filter_percentage, current_time);
124+
125+
double estimated_seconds_remaining = ukf.GetEstimatedRemainingSeconds();
60126
auto percentage_int = NormalizePercentage(percentage);
61-
if (percentage_int == rendered_percentage) {
62-
return;
63-
}
64-
PrintProgressInternal(percentage_int);
127+
PrintProgressInternal(percentage_int, estimated_seconds_remaining);
65128
Printer::Flush(OutputStream::STREAM_STDOUT);
66-
rendered_percentage = percentage_int;
67129
}
68130

69131
void TerminalProgressBarDisplay::Finish() {
70-
PrintProgressInternal(100);
132+
PrintProgressInternal(100, GetElapsedDuration(), true);
71133
Printer::RawPrint(OutputStream::STREAM_STDOUT, "\n");
72134
Printer::Flush(OutputStream::STREAM_STDOUT);
73135
}

0 commit comments

Comments
 (0)