duckdb 0.4.1-dev17.0 → 0.4.1-dev23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb.cpp +99 -7
- package/src/duckdb.hpp +2 -2
- package/src/parquet-amalgamation.cpp +35463 -35463
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -91605,18 +91605,22 @@ void DateSubFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
91605
91605
|
|
|
91606
91606
|
|
|
91607
91607
|
|
|
91608
|
+
|
|
91608
91609
|
namespace duckdb {
|
|
91609
91610
|
|
|
91610
91611
|
struct DateTrunc {
|
|
91612
|
+
template <class TA, class TR, class OP>
|
|
91613
|
+
static inline TR UnaryFunction(TA input) {
|
|
91614
|
+
if (Value::IsFinite(input)) {
|
|
91615
|
+
return OP::template Operation<TA, TR>(input);
|
|
91616
|
+
} else {
|
|
91617
|
+
return Cast::template Operation<TA, TR>(input);
|
|
91618
|
+
}
|
|
91619
|
+
}
|
|
91620
|
+
|
|
91611
91621
|
template <class TA, class TR, class OP>
|
|
91612
91622
|
static inline void UnaryExecute(Vector &left, Vector &result, idx_t count) {
|
|
91613
|
-
UnaryExecutor::Execute<TA, TR>(left, result, count,
|
|
91614
|
-
if (Value::IsFinite(input)) {
|
|
91615
|
-
return OP::template Operation<TA, TR>(input);
|
|
91616
|
-
} else {
|
|
91617
|
-
return Cast::template Operation<TA, TR>(input);
|
|
91618
|
-
}
|
|
91619
|
-
});
|
|
91623
|
+
UnaryExecutor::Execute<TA, TR>(left, result, count, UnaryFunction<TA, TR, OP>);
|
|
91620
91624
|
}
|
|
91621
91625
|
|
|
91622
91626
|
struct MillenniumOperator {
|
|
@@ -92179,6 +92183,82 @@ static void DateTruncFunction(DataChunk &args, ExpressionState &state, Vector &r
|
|
|
92179
92183
|
}
|
|
92180
92184
|
}
|
|
92181
92185
|
|
|
92186
|
+
template <class TA, class TR, class OP>
|
|
92187
|
+
static unique_ptr<BaseStatistics> DateTruncStatistics(vector<unique_ptr<BaseStatistics>> &child_stats) {
|
|
92188
|
+
// we can only propagate date stats if the child has stats
|
|
92189
|
+
if (!child_stats[1]) {
|
|
92190
|
+
return nullptr;
|
|
92191
|
+
}
|
|
92192
|
+
auto &nstats = (NumericStatistics &)*child_stats[1];
|
|
92193
|
+
if (nstats.min.IsNull() || nstats.max.IsNull()) {
|
|
92194
|
+
return nullptr;
|
|
92195
|
+
}
|
|
92196
|
+
// run the operator on both the min and the max, this gives us the [min, max] bound
|
|
92197
|
+
auto min = nstats.min.GetValueUnsafe<TA>();
|
|
92198
|
+
auto max = nstats.max.GetValueUnsafe<TA>();
|
|
92199
|
+
if (min > max) {
|
|
92200
|
+
throw InternalException("Invalid DATETRUNC child statistics");
|
|
92201
|
+
}
|
|
92202
|
+
|
|
92203
|
+
// Infinite values are unmodified
|
|
92204
|
+
auto min_part = DateTrunc::UnaryFunction<TA, TR, OP>(min);
|
|
92205
|
+
auto max_part = DateTrunc::UnaryFunction<TA, TR, OP>(max);
|
|
92206
|
+
|
|
92207
|
+
auto min_value = Value::CreateValue(min_part);
|
|
92208
|
+
auto max_value = Value::CreateValue(max_part);
|
|
92209
|
+
auto result = make_unique<NumericStatistics>(min_value.type(), min_value, max_value, StatisticsType::LOCAL_STATS);
|
|
92210
|
+
if (child_stats[0]->validity_stats) {
|
|
92211
|
+
result->validity_stats = child_stats[1]->validity_stats->Copy();
|
|
92212
|
+
}
|
|
92213
|
+
return move(result);
|
|
92214
|
+
}
|
|
92215
|
+
|
|
92216
|
+
template <class TA, class TR, class OP>
|
|
92217
|
+
static unique_ptr<BaseStatistics> PropagateDateTruncStatistics(ClientContext &context, FunctionStatisticsInput &input) {
|
|
92218
|
+
return DateTruncStatistics<TA, TR, OP>(input.child_stats);
|
|
92219
|
+
}
|
|
92220
|
+
|
|
92221
|
+
template <typename TA, typename TR>
|
|
92222
|
+
static function_statistics_t DateTruncStats(DatePartSpecifier type) {
|
|
92223
|
+
switch (type) {
|
|
92224
|
+
case DatePartSpecifier::MILLENNIUM:
|
|
92225
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::MillenniumOperator>;
|
|
92226
|
+
case DatePartSpecifier::CENTURY:
|
|
92227
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::CenturyOperator>;
|
|
92228
|
+
case DatePartSpecifier::DECADE:
|
|
92229
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::DecadeOperator>;
|
|
92230
|
+
case DatePartSpecifier::YEAR:
|
|
92231
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::YearOperator>;
|
|
92232
|
+
case DatePartSpecifier::QUARTER:
|
|
92233
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::QuarterOperator>;
|
|
92234
|
+
case DatePartSpecifier::MONTH:
|
|
92235
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::MonthOperator>;
|
|
92236
|
+
case DatePartSpecifier::WEEK:
|
|
92237
|
+
case DatePartSpecifier::YEARWEEK:
|
|
92238
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::WeekOperator>;
|
|
92239
|
+
case DatePartSpecifier::ISOYEAR:
|
|
92240
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::ISOYearOperator>;
|
|
92241
|
+
case DatePartSpecifier::DAY:
|
|
92242
|
+
case DatePartSpecifier::DOW:
|
|
92243
|
+
case DatePartSpecifier::ISODOW:
|
|
92244
|
+
case DatePartSpecifier::DOY:
|
|
92245
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::DayOperator>;
|
|
92246
|
+
case DatePartSpecifier::HOUR:
|
|
92247
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::HourOperator>;
|
|
92248
|
+
case DatePartSpecifier::MINUTE:
|
|
92249
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::MinuteOperator>;
|
|
92250
|
+
case DatePartSpecifier::SECOND:
|
|
92251
|
+
case DatePartSpecifier::EPOCH:
|
|
92252
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::SecondOperator>;
|
|
92253
|
+
case DatePartSpecifier::MILLISECONDS:
|
|
92254
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::MillisecondOperator>;
|
|
92255
|
+
case DatePartSpecifier::MICROSECONDS:
|
|
92256
|
+
return PropagateDateTruncStatistics<TA, TR, DateTrunc::MicrosecondOperator>;
|
|
92257
|
+
default:
|
|
92258
|
+
throw NotImplementedException("Specifier type not implemented for DATETRUNC statistics");
|
|
92259
|
+
}
|
|
92260
|
+
}
|
|
92261
|
+
|
|
92182
92262
|
static unique_ptr<FunctionData> DateTruncBind(ClientContext &context, ScalarFunction &bound_function,
|
|
92183
92263
|
vector<unique_ptr<Expression>> &arguments) {
|
|
92184
92264
|
if (!arguments[0]->IsFoldable()) {
|
|
@@ -92209,9 +92289,11 @@ static unique_ptr<FunctionData> DateTruncBind(ClientContext &context, ScalarFunc
|
|
|
92209
92289
|
switch (arguments[1]->return_type.id()) {
|
|
92210
92290
|
case LogicalType::TIMESTAMP:
|
|
92211
92291
|
bound_function.function = DateTruncFunction<timestamp_t, date_t>;
|
|
92292
|
+
bound_function.statistics = DateTruncStats<timestamp_t, date_t>(part_code);
|
|
92212
92293
|
break;
|
|
92213
92294
|
case LogicalType::DATE:
|
|
92214
92295
|
bound_function.function = DateTruncFunction<date_t, date_t>;
|
|
92296
|
+
bound_function.statistics = DateTruncStats<date_t, date_t>(part_code);
|
|
92215
92297
|
break;
|
|
92216
92298
|
default:
|
|
92217
92299
|
break;
|
|
@@ -92219,6 +92301,16 @@ static unique_ptr<FunctionData> DateTruncBind(ClientContext &context, ScalarFunc
|
|
|
92219
92301
|
bound_function.return_type = LogicalType::DATE;
|
|
92220
92302
|
break;
|
|
92221
92303
|
default:
|
|
92304
|
+
switch (arguments[1]->return_type.id()) {
|
|
92305
|
+
case LogicalType::TIMESTAMP:
|
|
92306
|
+
bound_function.statistics = DateTruncStats<timestamp_t, timestamp_t>(part_code);
|
|
92307
|
+
break;
|
|
92308
|
+
case LogicalType::DATE:
|
|
92309
|
+
bound_function.statistics = DateTruncStats<timestamp_t, date_t>(part_code);
|
|
92310
|
+
break;
|
|
92311
|
+
default:
|
|
92312
|
+
break;
|
|
92313
|
+
}
|
|
92222
92314
|
break;
|
|
92223
92315
|
}
|
|
92224
92316
|
|
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.4.1-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "2d5cbf201"
|
|
15
|
+
#define DUCKDB_VERSION "v0.4.1-dev23"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|