duckdb 0.2.10-dev358.0 → 0.2.10-dev437.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 +32 -20
- package/src/duckdb.hpp +6 -3
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -35991,7 +35991,7 @@ int64_t Interval::GetNanoseconds(interval_t val) {
|
|
|
35991
35991
|
|
|
35992
35992
|
return nano;
|
|
35993
35993
|
}
|
|
35994
|
-
interval_t Interval::
|
|
35994
|
+
interval_t Interval::GetAge(timestamp_t timestamp_1, timestamp_t timestamp_2) {
|
|
35995
35995
|
date_t date1, date2;
|
|
35996
35996
|
dtime_t time1, time2;
|
|
35997
35997
|
|
|
@@ -36079,6 +36079,18 @@ interval_t Interval::GetDifference(timestamp_t timestamp_1, timestamp_t timestam
|
|
|
36079
36079
|
|
|
36080
36080
|
return interval;
|
|
36081
36081
|
}
|
|
36082
|
+
interval_t Interval::GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2) {
|
|
36083
|
+
const auto us_1 = Timestamp::GetEpochMicroSeconds(timestamp_1);
|
|
36084
|
+
const auto us_2 = Timestamp::GetEpochMicroSeconds(timestamp_2);
|
|
36085
|
+
const auto delta_us = us_1 - us_2;
|
|
36086
|
+
|
|
36087
|
+
interval_t result;
|
|
36088
|
+
result.months = 0;
|
|
36089
|
+
result.days = delta_us / Interval::MICROS_PER_DAY;
|
|
36090
|
+
result.micros = delta_us % Interval::MICROS_PER_DAY;
|
|
36091
|
+
|
|
36092
|
+
return result;
|
|
36093
|
+
}
|
|
36082
36094
|
|
|
36083
36095
|
static void NormalizeIntervalEntries(interval_t input, int64_t &months, int64_t &days, int64_t µs) {
|
|
36084
36096
|
int64_t extra_months_d = input.days / Interval::DAYS_PER_MONTH;
|
|
@@ -64741,6 +64753,19 @@ void CheckForPerfectJoinOpt(LogicalComparisonJoin &op, PerfectHashJoinStats &joi
|
|
|
64741
64753
|
return;
|
|
64742
64754
|
}
|
|
64743
64755
|
|
|
64756
|
+
static void CanUseIndexJoin(TableScanBindData *tbl, Expression &expr, Index **result_index) {
|
|
64757
|
+
tbl->table->storage->info->indexes.Scan([&](Index &index) {
|
|
64758
|
+
if (index.unbound_expressions.size() != 1) {
|
|
64759
|
+
return false;
|
|
64760
|
+
}
|
|
64761
|
+
if (expr.alias == index.unbound_expressions[0]->alias) {
|
|
64762
|
+
*result_index = &index;
|
|
64763
|
+
return true;
|
|
64764
|
+
}
|
|
64765
|
+
return false;
|
|
64766
|
+
});
|
|
64767
|
+
}
|
|
64768
|
+
|
|
64744
64769
|
void TransformIndexJoin(ClientContext &context, LogicalComparisonJoin &op, Index **left_index, Index **right_index,
|
|
64745
64770
|
PhysicalOperator *left, PhysicalOperator *right) {
|
|
64746
64771
|
auto &transaction = Transaction::GetTransaction(context);
|
|
@@ -64752,26 +64777,14 @@ void TransformIndexJoin(ClientContext &context, LogicalComparisonJoin &op, Index
|
|
|
64752
64777
|
auto &tbl_scan = (PhysicalTableScan &)*left;
|
|
64753
64778
|
auto tbl = dynamic_cast<TableScanBindData *>(tbl_scan.bind_data.get());
|
|
64754
64779
|
if (CanPlanIndexJoin(transaction, tbl, tbl_scan)) {
|
|
64755
|
-
tbl
|
|
64756
|
-
if (index.unbound_expressions[0]->alias == op.conditions[0].left->alias) {
|
|
64757
|
-
*left_index = &index;
|
|
64758
|
-
return true;
|
|
64759
|
-
}
|
|
64760
|
-
return false;
|
|
64761
|
-
});
|
|
64780
|
+
CanUseIndexJoin(tbl, *op.conditions[0].left, left_index);
|
|
64762
64781
|
}
|
|
64763
64782
|
}
|
|
64764
64783
|
if (right->type == PhysicalOperatorType::TABLE_SCAN) {
|
|
64765
64784
|
auto &tbl_scan = (PhysicalTableScan &)*right;
|
|
64766
64785
|
auto tbl = dynamic_cast<TableScanBindData *>(tbl_scan.bind_data.get());
|
|
64767
64786
|
if (CanPlanIndexJoin(transaction, tbl, tbl_scan)) {
|
|
64768
|
-
tbl
|
|
64769
|
-
if (index.unbound_expressions[0]->alias == op.conditions[0].right->alias) {
|
|
64770
|
-
*right_index = &index;
|
|
64771
|
-
return true;
|
|
64772
|
-
}
|
|
64773
|
-
return false;
|
|
64774
|
-
});
|
|
64787
|
+
CanUseIndexJoin(tbl, *op.conditions[0].right, right_index);
|
|
64775
64788
|
}
|
|
64776
64789
|
}
|
|
64777
64790
|
}
|
|
@@ -76581,7 +76594,7 @@ static void AgeFunctionStandard(DataChunk &input, ExpressionState &state, Vector
|
|
|
76581
76594
|
auto current_timestamp = Timestamp::GetCurrentTimestamp();
|
|
76582
76595
|
|
|
76583
76596
|
UnaryExecutor::Execute<timestamp_t, interval_t>(input.data[0], result, input.size(), [&](timestamp_t input) {
|
|
76584
|
-
return Interval::
|
|
76597
|
+
return Interval::GetAge(current_timestamp, input);
|
|
76585
76598
|
});
|
|
76586
76599
|
}
|
|
76587
76600
|
|
|
@@ -76590,7 +76603,7 @@ static void AgeFunction(DataChunk &input, ExpressionState &state, Vector &result
|
|
|
76590
76603
|
|
|
76591
76604
|
BinaryExecutor::Execute<timestamp_t, timestamp_t, interval_t>(
|
|
76592
76605
|
input.data[0], input.data[1], result, input.size(),
|
|
76593
|
-
[&](timestamp_t input1, timestamp_t input2) { return Interval::
|
|
76606
|
+
[&](timestamp_t input1, timestamp_t input2) { return Interval::GetAge(input1, input2); });
|
|
76594
76607
|
}
|
|
76595
76608
|
|
|
76596
76609
|
void AgeFun::RegisterFunction(BuiltinFunctions &set) {
|
|
@@ -77960,7 +77973,7 @@ struct DateSub {
|
|
|
77960
77973
|
// Our interval difference will now give the correct result.
|
|
77961
77974
|
// Note that PG gives different interval subtraction results,
|
|
77962
77975
|
// so if we change this we will have to reimplement.
|
|
77963
|
-
return Interval::
|
|
77976
|
+
return Interval::GetAge(end_ts, start_ts).months;
|
|
77964
77977
|
}
|
|
77965
77978
|
};
|
|
77966
77979
|
|
|
@@ -129694,8 +129707,7 @@ SetScope ToSetScope(duckdb_libpgquery::VariableSetScope pg_scope) {
|
|
|
129694
129707
|
case duckdb_libpgquery::VariableSetScope::VAR_SET_SCOPE_GLOBAL:
|
|
129695
129708
|
return SetScope::GLOBAL;
|
|
129696
129709
|
case duckdb_libpgquery::VariableSetScope::VAR_SET_SCOPE_DEFAULT:
|
|
129697
|
-
|
|
129698
|
-
return SetScope::GLOBAL;
|
|
129710
|
+
return SetScope::SESSION;
|
|
129699
129711
|
default:
|
|
129700
129712
|
throw InternalException("Unexpected pg_scope: %d", pg_scope);
|
|
129701
129713
|
}
|
package/src/duckdb.hpp
CHANGED
|
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
|
-
#define DUCKDB_SOURCE_ID "
|
|
14
|
-
#define DUCKDB_VERSION "0.2.10-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "ca1fe636e"
|
|
14
|
+
#define DUCKDB_VERSION "0.2.10-dev437"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|
|
@@ -5964,7 +5964,10 @@ public:
|
|
|
5964
5964
|
//! Get Interval in Nanoseconds
|
|
5965
5965
|
static int64_t GetNanoseconds(interval_t val);
|
|
5966
5966
|
|
|
5967
|
-
//! Returns the
|
|
5967
|
+
//! Returns the age between two timestamps (including 30 day months)
|
|
5968
|
+
static interval_t GetAge(timestamp_t timestamp_1, timestamp_t timestamp_2);
|
|
5969
|
+
|
|
5970
|
+
//! Returns the exact difference between two timestamps (days and seconds)
|
|
5968
5971
|
static interval_t GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2);
|
|
5969
5972
|
|
|
5970
5973
|
//! Comparison operators
|