Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/duckdb/extension/icu/icu-strptime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,14 @@ struct ICUStrptime : public ICUDateFunc {
auto &info = cast_data.info->Cast<BindData>();
CalendarPtr cal(info.calendar->clone());

UnaryExecutor::ExecuteWithNulls<string_t, timestamp_t>(
UnaryExecutor::ExecuteWithNulls<string_t, timestamp_tz_t>(
source, result, count, [&](string_t input, ValidityMask &mask, idx_t idx) {
timestamp_t result;
timestamp_tz_t result;
const auto str = input.GetData();
const auto len = input.GetSize();
string_t tz(nullptr, 0);
bool has_offset = false;
auto success = Timestamp::TryConvertTimestampTZ(str, len, result, has_offset, tz);
auto success = Timestamp::TryConvertTimestampTZ(str, len, result, true, has_offset, tz);
if (success != TimestampCastResult::SUCCESS) {
string msg;
if (success == TimestampCastResult::ERROR_RANGE) {
Expand All @@ -302,7 +302,7 @@ struct ICUStrptime : public ICUDateFunc {
}

// Now get the parts in the given time zone
result = FromNaive(calendar, result);
result = timestamp_tz_t(FromNaive(calendar, result));
}

return result;
Expand Down
6 changes: 5 additions & 1 deletion src/duckdb/src/common/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,11 @@ vector<OpenFileInfo> FileSystem::GlobFiles(const string &pattern, ClientContext
throw InternalException("FALLBACK_GLOB requires an extension to be specified");
}
string new_pattern = JoinPath(JoinPath(pattern, "**"), "*." + input.extension);
return GlobFiles(new_pattern, context, FileGlobOptions::DISALLOW_EMPTY);
result = GlobFiles(new_pattern, context, FileGlobOptions::ALLOW_EMPTY);
if (!result.empty()) {
// we found files by globbing the target as if it was a directory - return them
return result;
}
}
}
if (input.behavior == FileGlobOptions::FALLBACK_GLOB || input.behavior == FileGlobOptions::DISALLOW_EMPTY) {
Expand Down
39 changes: 35 additions & 4 deletions src/duckdb/src/common/operator/cast_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,26 @@ dtime_tz_t Cast::Operation(string_t input) {
//===--------------------------------------------------------------------===//
template <>
bool TryCastErrorMessage::Operation(string_t input, timestamp_t &result, CastParameters &parameters) {
switch (Timestamp::TryConvertTimestamp(input.GetData(), input.GetSize(), result)) {
switch (Timestamp::TryConvertTimestamp(input.GetData(), input.GetSize(), result, false)) {
case TimestampCastResult::SUCCESS:
case TimestampCastResult::STRICT_UTC:
return true;
case TimestampCastResult::ERROR_INCORRECT_FORMAT:
HandleCastError::AssignError(Timestamp::FormatError(input), parameters);
break;
case TimestampCastResult::ERROR_NON_UTC_TIMEZONE:
HandleCastError::AssignError(Timestamp::UnsupportedTimezoneError(input), parameters);
break;
case TimestampCastResult::ERROR_RANGE:
HandleCastError::AssignError(Timestamp::RangeError(input), parameters);
break;
}
return false;
}

template <>
bool TryCastErrorMessage::Operation(string_t input, timestamp_tz_t &result, CastParameters &parameters) {
switch (Timestamp::TryConvertTimestamp(input.GetData(), input.GetSize(), result, true)) {
case TimestampCastResult::SUCCESS:
case TimestampCastResult::STRICT_UTC:
return true;
Expand All @@ -1703,7 +1722,14 @@ bool TryCastErrorMessage::Operation(string_t input, timestamp_t &result, CastPar

template <>
bool TryCast::Operation(string_t input, timestamp_t &result, bool strict) {
return Timestamp::TryConvertTimestamp(input.GetData(), input.GetSize(), result) == TimestampCastResult::SUCCESS;
return Timestamp::TryConvertTimestamp(input.GetData(), input.GetSize(), result, false) ==
TimestampCastResult::SUCCESS;
}

template <>
bool TryCast::Operation(string_t input, timestamp_tz_t &result, bool strict) {
return Timestamp::TryConvertTimestamp(input.GetData(), input.GetSize(), result, true) ==
TimestampCastResult::SUCCESS;
}

template <>
Expand All @@ -1713,13 +1739,18 @@ bool TryCast::Operation(string_t input, timestamp_ns_t &result, bool strict) {

template <>
timestamp_t Cast::Operation(string_t input) {
return Timestamp::FromCString(input.GetData(), input.GetSize());
return Timestamp::FromCString(input.GetData(), input.GetSize(), false);
}

template <>
timestamp_tz_t Cast::Operation(string_t input) {
return timestamp_tz_t(Timestamp::FromCString(input.GetData(), input.GetSize(), true));
}

template <>
timestamp_ns_t Cast::Operation(string_t input) {
int32_t nanos;
const auto ts = Timestamp::FromCString(input.GetData(), input.GetSize(), &nanos);
const auto ts = Timestamp::FromCString(input.GetData(), input.GetSize(), false, &nanos);
timestamp_ns_t result;
if (!Timestamp::TryFromTimestampNanos(ts, nanos, result)) {
throw ConversionException(Timestamp::RangeError(input));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ void TerminalProgressBarDisplay::Update(double percentage) {

double estimated_seconds_remaining = ukf.GetEstimatedRemainingSeconds();
auto percentage_int = NormalizePercentage(percentage);
PrintProgressInternal(percentage_int, estimated_seconds_remaining);
Printer::Flush(OutputStream::STREAM_STDOUT);

TerminalProgressBarDisplayedProgressInfo updated_progress_info = {percentage_int,
(int32_t)estimated_seconds_remaining};
if (displayed_progress_info != updated_progress_info) {
PrintProgressInternal(percentage_int, estimated_seconds_remaining);
Printer::Flush(OutputStream::STREAM_STDOUT);
displayed_progress_info = updated_progress_info;
}
}

void TerminalProgressBarDisplay::Finish() {
Expand Down
1 change: 0 additions & 1 deletion src/duckdb/src/common/sorting/hashed_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ SinkFinalizeType HashedSort::MaterializeHashGroups(Pipeline &pipeline, Event &ev
}

// Schedule all the sorts for maximum thread utilisation
HashedSortMaterializeEvent fnord(gsink, pipeline, op, callback);
auto sort_event = make_shared_ptr<HashedSortMaterializeEvent>(gsink, pipeline, op, callback);
event.InsertEvent(std::move(sort_event));

Expand Down
4 changes: 2 additions & 2 deletions src/duckdb/src/common/types/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool Time::TryConvertTime(const char *buf, idx_t len, idx_t &pos, dtime_t &resul
if (!strict) {
// last chance, check if we can parse as timestamp
timestamp_t timestamp;
if (Timestamp::TryConvertTimestamp(buf, len, timestamp, nanos) == TimestampCastResult::SUCCESS) {
if (Timestamp::TryConvertTimestamp(buf, len, timestamp, false, nanos) == TimestampCastResult::SUCCESS) {
if (!Timestamp::IsFinite(timestamp)) {
return false;
}
Expand All @@ -164,7 +164,7 @@ bool Time::TryConvertTimeTZ(const char *buf, idx_t len, idx_t &pos, dtime_tz_t &
if (!strict) {
// last chance, check if we can parse as timestamp
timestamp_t timestamp;
if (Timestamp::TryConvertTimestamp(buf, len, timestamp, nanos) == TimestampCastResult::SUCCESS) {
if (Timestamp::TryConvertTimestamp(buf, len, timestamp, true, nanos) == TimestampCastResult::SUCCESS) {
if (!Timestamp::IsFinite(timestamp)) {
return false;
}
Expand Down
20 changes: 10 additions & 10 deletions src/duckdb/src/common/types/timestamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ timestamp_t &timestamp_t::operator-=(const int64_t &delta) {
return *this;
}

TimestampCastResult Timestamp::TryConvertTimestampTZ(const char *str, idx_t len, timestamp_t &result, bool &has_offset,
string_t &tz, optional_ptr<int32_t> nanos) {
TimestampCastResult Timestamp::TryConvertTimestampTZ(const char *str, idx_t len, timestamp_t &result, bool use_offset,
bool &has_offset, string_t &tz, optional_ptr<int32_t> nanos) {
idx_t pos;
date_t date;
dtime_t time;
Expand Down Expand Up @@ -118,7 +118,7 @@ TimestampCastResult Timestamp::TryConvertTimestampTZ(const char *str, idx_t len,
} else if (Timestamp::TryParseUTCOffset(str, pos, len, hh, mm, ss)) {
const int64_t delta =
hh * Interval::MICROS_PER_HOUR + mm * Interval::MICROS_PER_MINUTE + ss * Interval::MICROS_PER_SEC;
if (!TrySubtractOperator::Operation(result.value, delta, result.value)) {
if (use_offset && !TrySubtractOperator::Operation(result.value, delta, result.value)) {
return TimestampCastResult::ERROR_RANGE;
}
has_offset = true;
Expand Down Expand Up @@ -149,12 +149,12 @@ TimestampCastResult Timestamp::TryConvertTimestampTZ(const char *str, idx_t len,
return TimestampCastResult::SUCCESS;
}

TimestampCastResult Timestamp::TryConvertTimestamp(const char *str, idx_t len, timestamp_t &result,
TimestampCastResult Timestamp::TryConvertTimestamp(const char *str, idx_t len, timestamp_t &result, bool use_offset,
optional_ptr<int32_t> nanos, bool strict) {
string_t tz(nullptr, 0);
bool has_offset = false;
// We don't understand TZ without an extension, so fail if one was provided.
auto success = TryConvertTimestampTZ(str, len, result, has_offset, tz, nanos);
auto success = TryConvertTimestampTZ(str, len, result, use_offset, has_offset, tz, nanos);
if (success != TimestampCastResult::SUCCESS) {
return success;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ bool Timestamp::TryFromTimestampNanos(timestamp_t input, int32_t nanos, timestam

TimestampCastResult Timestamp::TryConvertTimestamp(const char *str, idx_t len, timestamp_ns_t &result) {
int32_t nanos = 0;
auto success = TryConvertTimestamp(str, len, result, &nanos);
auto success = TryConvertTimestamp(str, len, result, true, &nanos);
if (success != TimestampCastResult::SUCCESS) {
return success;
}
Expand Down Expand Up @@ -236,9 +236,9 @@ string Timestamp::RangeError(string_t str) {
return Timestamp::RangeError(str.GetString());
}

timestamp_t Timestamp::FromCString(const char *str, idx_t len, optional_ptr<int32_t> nanos) {
timestamp_t Timestamp::FromCString(const char *str, idx_t len, bool use_offset, optional_ptr<int32_t> nanos) {
timestamp_t result;
switch (Timestamp::TryConvertTimestamp(str, len, result, nanos)) {
switch (Timestamp::TryConvertTimestamp(str, len, result, use_offset, nanos)) {
case TimestampCastResult::SUCCESS:
case TimestampCastResult::STRICT_UTC:
break;
Expand Down Expand Up @@ -324,8 +324,8 @@ bool Timestamp::TryParseUTCOffset(const char *str, idx_t &pos, idx_t len, int &h
return true;
}

timestamp_t Timestamp::FromString(const string &str) {
return Timestamp::FromCString(str.c_str(), str.size());
timestamp_t Timestamp::FromString(const string &str, bool use_offset) {
return Timestamp::FromCString(str.c_str(), str.size(), use_offset);
}

string Timestamp::ToString(timestamp_t timestamp) {
Expand Down
6 changes: 3 additions & 3 deletions src/duckdb/src/common/types/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,12 +755,12 @@ Value Vector::GetValueInternal(const Vector &v_p, idx_t index_p) {
case LogicalTypeId::STRUCT: {
// we can derive the value schema from the vector schema
auto &child_entries = StructVector::GetEntries(*vector);
child_list_t<Value> children;
duckdb::vector<Value> children;
for (idx_t child_idx = 0; child_idx < child_entries.size(); child_idx++) {
auto &struct_child = child_entries[child_idx];
children.push_back(make_pair(StructType::GetChildName(type, child_idx), struct_child->GetValue(index_p)));
children.push_back(struct_child->GetValue(index_p));
}
return Value::STRUCT(std::move(children));
return Value::STRUCT(type, std::move(children));
}
case LogicalTypeId::LIST: {
auto offlen = reinterpret_cast<list_entry_t *>(data)[index];
Expand Down
Loading
Loading