Skip to content

Commit 823a3a4

Browse files
authored
Merge pull request #10 from duckdb/updatevendoredsourcesv0.10.3
update vendored sources to 0.10.3
2 parents 4f62ac7 + fc6c3f6 commit 823a3a4

File tree

905 files changed

+57722
-31058
lines changed

Some content is hidden

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

905 files changed

+57722
-31058
lines changed

Diff for: CMakeLists.txt

+2-2
Large diffs are not rendered by default.

Diff for: src/duckdb/extension/icu/icu_extension.cpp

+44-15
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,35 @@ struct IcuBindData : public FunctionData {
6262
auto &other = other_p.Cast<IcuBindData>();
6363
return language == other.language && country == other.country;
6464
}
65+
66+
static void Serialize(Serializer &serializer, const optional_ptr<FunctionData> bind_data_p,
67+
const ScalarFunction &function) {
68+
auto &bind_data = bind_data_p->Cast<IcuBindData>();
69+
serializer.WriteProperty(100, "language", bind_data.language);
70+
serializer.WriteProperty(101, "country", bind_data.country);
71+
}
72+
73+
static unique_ptr<FunctionData> Deserialize(Deserializer &deserializer, ScalarFunction &function) {
74+
string language;
75+
string country;
76+
deserializer.ReadProperty(100, "language", language);
77+
deserializer.ReadProperty(101, "country", country);
78+
79+
return make_uniq<IcuBindData>(language, country);
80+
}
81+
82+
static const string FUNCTION_PREFIX;
83+
84+
static string EncodeFunctionName(const string &collation) {
85+
return FUNCTION_PREFIX + collation;
86+
}
87+
static string DecodeFunctionName(const string &fname) {
88+
return fname.substr(FUNCTION_PREFIX.size());
89+
}
6590
};
6691

92+
const string IcuBindData::FUNCTION_PREFIX = "icu_collate_";
93+
6794
static int32_t ICUGetSortKey(icu::Collator &collator, string_t input, duckdb::unique_ptr<char[]> &buffer,
6895
int32_t &buffer_size) {
6996
icu::UnicodeString unicode_string =
@@ -108,7 +135,9 @@ static void ICUCollateFunction(DataChunk &args, ExpressionState &state, Vector &
108135

109136
static duckdb::unique_ptr<FunctionData> ICUCollateBind(ClientContext &context, ScalarFunction &bound_function,
110137
vector<duckdb::unique_ptr<Expression>> &arguments) {
111-
auto splits = StringUtil::Split(bound_function.name, "_");
138+
139+
const auto collation = IcuBindData::DecodeFunctionName(bound_function.name);
140+
auto splits = StringUtil::Split(collation, "_");
112141
if (splits.size() == 1) {
113142
return make_uniq<IcuBindData>(splits[0], "");
114143
} else if (splits.size() == 2) {
@@ -137,19 +166,11 @@ static duckdb::unique_ptr<FunctionData> ICUSortKeyBind(ClientContext &context, S
137166
}
138167
}
139168

140-
static void ICUCollateSerialize(Serializer &serializer, const optional_ptr<FunctionData> bind_data,
141-
const ScalarFunction &function) {
142-
throw NotImplementedException("FIXME: serialize icu-collate");
143-
}
144-
145-
static duckdb::unique_ptr<FunctionData> ICUCollateDeserialize(Deserializer &deserializer, ScalarFunction &function) {
146-
throw NotImplementedException("FIXME: serialize icu-collate");
147-
}
148-
149-
static ScalarFunction GetICUFunction(const string &collation) {
150-
ScalarFunction result(collation, {LogicalType::VARCHAR}, LogicalType::VARCHAR, ICUCollateFunction, ICUCollateBind);
151-
result.serialize = ICUCollateSerialize;
152-
result.deserialize = ICUCollateDeserialize;
169+
static ScalarFunction GetICUCollateFunction(const string &collation) {
170+
string fname = IcuBindData::EncodeFunctionName(collation);
171+
ScalarFunction result(fname, {LogicalType::VARCHAR}, LogicalType::VARCHAR, ICUCollateFunction, ICUCollateBind);
172+
result.serialize = IcuBindData::Serialize;
173+
result.deserialize = IcuBindData::Deserialize;
153174
return result;
154175
}
155176

@@ -238,7 +259,7 @@ static void LoadInternal(DuckDB &ddb) {
238259
}
239260
collation = StringUtil::Lower(collation);
240261

241-
CreateCollationInfo info(collation, GetICUFunction(collation), false, false);
262+
CreateCollationInfo info(collation, GetICUCollateFunction(collation), false, false);
242263
ExtensionUtil::RegisterCollation(db, info);
243264
}
244265
ScalarFunction sort_key("icu_sort_key", {LogicalType::VARCHAR, LogicalType::VARCHAR}, LogicalType::VARCHAR,
@@ -283,6 +304,14 @@ std::string IcuExtension::Name() {
283304
return "icu";
284305
}
285306

307+
std::string IcuExtension::Version() const {
308+
#ifdef EXT_VERSION_ICU
309+
return EXT_VERSION_ICU;
310+
#else
311+
return "";
312+
#endif
313+
}
314+
286315
} // namespace duckdb
287316

288317
extern "C" {

Diff for: src/duckdb/extension/icu/include/icu_extension.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class IcuExtension : public Extension {
1616
public:
1717
void Load(DuckDB &db) override;
1818
std::string Name() override;
19+
std::string Version() const override;
1920
};
2021

2122
} // namespace duckdb

Diff for: src/duckdb/extension/icu/third_party/icu/i18n/basictz.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ BasicTimeZone::hasEquivalentTransitions(const BasicTimeZone& tz, UDate start, UD
6363
} else {
6464
if (raw1 != raw2 || dst1 != dst2) {
6565
return FALSE;
66-
}
66+
}
6767
}
6868
// Check transitions in the range
6969
UDate time = start;
@@ -159,7 +159,7 @@ BasicTimeZone::getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
159159
if (((tr.getFrom()->getDSTSavings() == 0 && tr.getTo()->getDSTSavings() != 0)
160160
|| (tr.getFrom()->getDSTSavings() != 0 && tr.getTo()->getDSTSavings() == 0))
161161
&& (date + MILLIS_PER_YEAR > nextTransitionTime)) {
162-
162+
163163
int32_t year, month, dom, dow, doy, mid;
164164
UDate d;
165165

@@ -375,13 +375,13 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial,
375375
UDate updatedTime = tzt.getTime();
376376
if (updatedTime == time) {
377377
// Can get here if rules for start & end of daylight time have exactly
378-
// the same time.
378+
// the same time.
379379
// TODO: fix getNextTransition() to prevent it?
380380
status = U_INVALID_STATE_ERROR;
381381
goto error;
382382
}
383383
time = updatedTime;
384-
384+
385385
const TimeZoneRule *toRule = tzt.getTo();
386386
for (i = 0; i < ruleCount; i++) {
387387
r = (TimeZoneRule*)orgRules->elementAt(i);
@@ -408,7 +408,7 @@ BasicTimeZone::getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial,
408408
if (!avail) {
409409
break;
410410
}
411-
if (*(tzt0.getTo()) == *tar) {
411+
if (*tar == *(tzt0.getTo())) {
412412
break;
413413
}
414414
t = tzt0.getTime();

Diff for: src/duckdb/extension/json/include/json_common.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "duckdb/planner/expression/bound_function_expression.hpp"
1515
#include "yyjson.hpp"
1616

17+
using namespace duckdb_yyjson; // NOLINT
18+
1719
namespace duckdb {
1820

1921
//! JSON allocator is a custom allocator for yyjson that prevents many tiny allocations
@@ -108,6 +110,7 @@ struct JSONCommon {
108110
switch (yyjson_get_tag(val)) {
109111
case YYJSON_TYPE_NULL | YYJSON_SUBTYPE_NONE:
110112
return JSONCommon::TYPE_STRING_NULL;
113+
case YYJSON_TYPE_STR | YYJSON_SUBTYPE_NOESC:
111114
case YYJSON_TYPE_STR | YYJSON_SUBTYPE_NONE:
112115
return JSONCommon::TYPE_STRING_VARCHAR;
113116
case YYJSON_TYPE_ARR | YYJSON_SUBTYPE_NONE:
@@ -136,6 +139,7 @@ struct JSONCommon {
136139
switch (yyjson_get_tag(val)) {
137140
case YYJSON_TYPE_NULL | YYJSON_SUBTYPE_NONE:
138141
return LogicalTypeId::SQLNULL;
142+
case YYJSON_TYPE_STR | YYJSON_SUBTYPE_NOESC:
139143
case YYJSON_TYPE_STR | YYJSON_SUBTYPE_NONE:
140144
return LogicalTypeId::VARCHAR;
141145
case YYJSON_TYPE_ARR | YYJSON_SUBTYPE_NONE:
@@ -286,7 +290,8 @@ struct JSONCommon {
286290
private:
287291
//! Get JSON pointer (/field/index/... syntax)
288292
static inline yyjson_val *GetPointer(yyjson_val *val, const char *ptr, const idx_t &len) {
289-
return len == 1 ? val : unsafe_yyjson_get_pointer(val, ptr, len);
293+
yyjson_ptr_err err;
294+
return len == 1 ? val : unsafe_yyjson_ptr_getx(val, ptr, len, &err);
290295
}
291296
//! Get JSON path ($.field[index]... syntax)
292297
static yyjson_val *GetPath(yyjson_val *val, const char *ptr, const idx_t &len);

Diff for: src/duckdb/extension/json/include/json_executors.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct JSONExecutors {
3030
}
3131

3232
//! Two-argument JSON read function (with path query), i.e. json_type('[1, 2, 3]', '$[0]')
33-
template <class T>
33+
template <class T, bool NULL_IF_NULL = true>
3434
static void BinaryExecute(DataChunk &args, ExpressionState &state, Vector &result,
3535
std::function<T(yyjson_val *, yyjson_alc *, Vector &)> fun) {
3636
auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
@@ -48,7 +48,7 @@ struct JSONExecutors {
4848
auto doc =
4949
JSONCommon::ReadDocument(input, JSONCommon::READ_FLAG, lstate.json_allocator.GetYYAlc());
5050
auto val = JSONCommon::GetUnsafe(doc->root, ptr, len);
51-
if (!val || unsafe_yyjson_is_null(val)) {
51+
if (!val || (NULL_IF_NULL && unsafe_yyjson_is_null(val))) {
5252
mask.SetInvalid(idx);
5353
return T {};
5454
} else {
@@ -76,7 +76,7 @@ struct JSONExecutors {
7676
for (idx_t i = 0; i < vals.size(); i++) {
7777
auto &val = vals[i];
7878
D_ASSERT(val != nullptr); // Wildcard extract shouldn't give back nullptrs
79-
if (unsafe_yyjson_is_null(val)) {
79+
if (NULL_IF_NULL && unsafe_yyjson_is_null(val)) {
8080
child_validity.SetInvalid(current_size + i);
8181
} else {
8282
child_vals[current_size + i] = fun(val, alc, result);
@@ -109,7 +109,7 @@ struct JSONExecutors {
109109
}
110110

111111
//! JSON read function with list of path queries, i.e. json_type('[1, 2, 3]', ['$[0]', '$[1]'])
112-
template <class T>
112+
template <class T, bool NULL_IF_NULL = true>
113113
static void ExecuteMany(DataChunk &args, ExpressionState &state, Vector &result,
114114
std::function<T(yyjson_val *, yyjson_alc *, Vector &)> fun) {
115115
auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
@@ -148,7 +148,7 @@ struct JSONExecutors {
148148
for (idx_t path_i = 0; path_i < num_paths; path_i++) {
149149
auto child_idx = offset + path_i;
150150
val = JSONCommon::GetUnsafe(doc->root, info.ptrs[path_i], info.lens[path_i]);
151-
if (!val || unsafe_yyjson_is_null(val)) {
151+
if (!val || (NULL_IF_NULL && unsafe_yyjson_is_null(val))) {
152152
child_validity.SetInvalid(child_idx);
153153
} else {
154154
child_data[child_idx] = fun(val, alc, child);

Diff for: src/duckdb/extension/json/include/json_extension.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class JsonExtension : public Extension {
1616
public:
1717
void Load(DuckDB &db) override;
1818
std::string Name() override;
19+
std::string Version() const override;
1920
};
2021

2122
} // namespace duckdb

Diff for: src/duckdb/extension/json/include/json_functions.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class JSONFunctions {
7070
static vector<ScalarFunctionSet> GetScalarFunctions();
7171
static vector<PragmaFunctionSet> GetPragmaFunctions();
7272
static vector<TableFunctionSet> GetTableFunctions();
73-
static unique_ptr<TableRef> ReadJSONReplacement(ClientContext &context, const string &table_name,
74-
ReplacementScanData *data);
73+
static unique_ptr<TableRef> ReadJSONReplacement(ClientContext &context, ReplacementScanInput &input,
74+
optional_ptr<ReplacementScanData> data);
7575
static TableFunction GetReadJSONTableFunction(shared_ptr<JSONScanInfo> function_info);
7676
static CopyFunction GetJSONCopyFunction();
7777
static void RegisterSimpleCastFunctions(CastFunctionSet &casts);

Diff for: src/duckdb/extension/json/include/json_serializer.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ struct JsonSerializer : Serializer {
2727
public:
2828
explicit JsonSerializer(yyjson_mut_doc *doc, bool skip_if_null, bool skip_if_empty, bool skip_if_default)
2929
: doc(doc), stack({yyjson_mut_obj(doc)}), skip_if_null(skip_if_null), skip_if_empty(skip_if_empty) {
30-
serialize_enum_as_string = true;
31-
serialize_default_values = !skip_if_default;
30+
options.serialize_enum_as_string = true;
31+
options.serialize_default_values = !skip_if_default;
3232
}
3333

3434
template <class T>

0 commit comments

Comments
 (0)