duckdb 0.3.2-dev362.0 → 0.3.2-dev396.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 +540 -42
- package/src/duckdb.hpp +67 -45
package/src/duckdb.cpp
CHANGED
|
@@ -4703,6 +4703,15 @@ void Catalog::DropEntry(ClientContext &context, DropInfo *info) {
|
|
|
4703
4703
|
lookup.schema->DropEntry(context, info);
|
|
4704
4704
|
}
|
|
4705
4705
|
|
|
4706
|
+
CatalogEntry *Catalog::AddFunction(ClientContext &context, CreateFunctionInfo *info) {
|
|
4707
|
+
auto schema = GetSchema(context, info->schema);
|
|
4708
|
+
return AddFunction(context, schema, info);
|
|
4709
|
+
}
|
|
4710
|
+
|
|
4711
|
+
CatalogEntry *Catalog::AddFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateFunctionInfo *info) {
|
|
4712
|
+
return schema->AddFunction(context, info);
|
|
4713
|
+
}
|
|
4714
|
+
|
|
4706
4715
|
SchemaCatalogEntry *Catalog::GetSchema(ClientContext &context, const string &schema_name, bool if_exists,
|
|
4707
4716
|
QueryErrorContext error_context) {
|
|
4708
4717
|
D_ASSERT(!schema_name.empty());
|
|
@@ -6659,6 +6668,37 @@ CatalogEntry *SchemaCatalogEntry::CreateFunction(ClientContext &context, CreateF
|
|
|
6659
6668
|
return AddEntry(context, move(function), info->on_conflict);
|
|
6660
6669
|
}
|
|
6661
6670
|
|
|
6671
|
+
CatalogEntry *SchemaCatalogEntry::AddFunction(ClientContext &context, CreateFunctionInfo *info) {
|
|
6672
|
+
auto entry = GetCatalogSet(info->type).GetEntry(context, info->name);
|
|
6673
|
+
if (!entry) {
|
|
6674
|
+
return CreateFunction(context, info);
|
|
6675
|
+
}
|
|
6676
|
+
|
|
6677
|
+
info->on_conflict = OnCreateConflict::REPLACE_ON_CONFLICT;
|
|
6678
|
+
switch (info->type) {
|
|
6679
|
+
case CatalogType::SCALAR_FUNCTION_ENTRY: {
|
|
6680
|
+
auto scalar_info = (CreateScalarFunctionInfo *)info;
|
|
6681
|
+
auto &scalars = *(ScalarFunctionCatalogEntry *)entry;
|
|
6682
|
+
for (const auto &scalar : scalars.functions) {
|
|
6683
|
+
scalar_info->functions.emplace_back(scalar);
|
|
6684
|
+
}
|
|
6685
|
+
break;
|
|
6686
|
+
}
|
|
6687
|
+
case CatalogType::AGGREGATE_FUNCTION_ENTRY: {
|
|
6688
|
+
auto agg_info = (CreateAggregateFunctionInfo *)info;
|
|
6689
|
+
auto &aggs = *(AggregateFunctionCatalogEntry *)entry;
|
|
6690
|
+
for (const auto &agg : aggs.functions) {
|
|
6691
|
+
agg_info->functions.AddFunction(agg);
|
|
6692
|
+
}
|
|
6693
|
+
break;
|
|
6694
|
+
}
|
|
6695
|
+
default:
|
|
6696
|
+
// Macros can only be replaced because there is only one of each name.
|
|
6697
|
+
throw InternalException("Unsupported function type \"%s\" for adding", CatalogTypeToString(info->type));
|
|
6698
|
+
}
|
|
6699
|
+
return CreateFunction(context, info);
|
|
6700
|
+
}
|
|
6701
|
+
|
|
6662
6702
|
void SchemaCatalogEntry::DropEntry(ClientContext &context, DropInfo *info) {
|
|
6663
6703
|
auto &set = GetCatalogSet(info->type);
|
|
6664
6704
|
|
|
@@ -22880,6 +22920,21 @@ duckdb::string_t StringCast::Operation(dtime_t input, Vector &result);
|
|
|
22880
22920
|
template <>
|
|
22881
22921
|
duckdb::string_t StringCast::Operation(timestamp_t input, Vector &result);
|
|
22882
22922
|
|
|
22923
|
+
//! Temporary casting for Time Zone types. TODO: turn casting into functions.
|
|
22924
|
+
struct StringCastTZ {
|
|
22925
|
+
template <typename SRC>
|
|
22926
|
+
static inline string_t Operation(SRC input, Vector &vector) {
|
|
22927
|
+
return StringCast::Operation(input, vector);
|
|
22928
|
+
}
|
|
22929
|
+
};
|
|
22930
|
+
|
|
22931
|
+
template <>
|
|
22932
|
+
duckdb::string_t StringCastTZ::Operation(date_t input, Vector &result);
|
|
22933
|
+
template <>
|
|
22934
|
+
duckdb::string_t StringCastTZ::Operation(dtime_t input, Vector &result);
|
|
22935
|
+
template <>
|
|
22936
|
+
duckdb::string_t StringCastTZ::Operation(timestamp_t input, Vector &result);
|
|
22937
|
+
|
|
22883
22938
|
} // namespace duckdb
|
|
22884
22939
|
|
|
22885
22940
|
//===----------------------------------------------------------------------===//
|
|
@@ -26678,6 +26733,90 @@ duckdb::string_t StringCast::Operation(duckdb::string_t input, Vector &result) {
|
|
|
26678
26733
|
return StringVector::AddStringOrBlob(result, input);
|
|
26679
26734
|
}
|
|
26680
26735
|
|
|
26736
|
+
template <>
|
|
26737
|
+
string_t StringCastTZ::Operation(date_t input, Vector &vector) {
|
|
26738
|
+
int32_t date[3];
|
|
26739
|
+
Date::Convert(input, date[0], date[1], date[2]);
|
|
26740
|
+
|
|
26741
|
+
// format for datetz is DATE+00
|
|
26742
|
+
idx_t year_length;
|
|
26743
|
+
bool add_bc;
|
|
26744
|
+
const idx_t date_length = DateToStringCast::Length(date, year_length, add_bc);
|
|
26745
|
+
const idx_t length = date_length + 3;
|
|
26746
|
+
|
|
26747
|
+
string_t result = StringVector::EmptyString(vector, length);
|
|
26748
|
+
auto data = result.GetDataWriteable();
|
|
26749
|
+
|
|
26750
|
+
idx_t pos = 0;
|
|
26751
|
+
DateToStringCast::Format(data + pos, date, year_length, add_bc);
|
|
26752
|
+
pos += date_length;
|
|
26753
|
+
data[pos++] = '+';
|
|
26754
|
+
data[pos++] = '0';
|
|
26755
|
+
data[pos++] = '0';
|
|
26756
|
+
|
|
26757
|
+
result.Finalize();
|
|
26758
|
+
return result;
|
|
26759
|
+
}
|
|
26760
|
+
|
|
26761
|
+
template <>
|
|
26762
|
+
string_t StringCastTZ::Operation(dtime_t input, Vector &vector) {
|
|
26763
|
+
int32_t time[4];
|
|
26764
|
+
Time::Convert(input, time[0], time[1], time[2], time[3]);
|
|
26765
|
+
|
|
26766
|
+
// format for timetz is TIME+00
|
|
26767
|
+
char micro_buffer[10];
|
|
26768
|
+
const auto time_length = TimeToStringCast::Length(time, micro_buffer);
|
|
26769
|
+
const idx_t length = time_length + 3;
|
|
26770
|
+
|
|
26771
|
+
string_t result = StringVector::EmptyString(vector, length);
|
|
26772
|
+
auto data = result.GetDataWriteable();
|
|
26773
|
+
|
|
26774
|
+
idx_t pos = 0;
|
|
26775
|
+
TimeToStringCast::Format(data + pos, length, time, micro_buffer);
|
|
26776
|
+
pos += time_length;
|
|
26777
|
+
data[pos++] = '+';
|
|
26778
|
+
data[pos++] = '0';
|
|
26779
|
+
data[pos++] = '0';
|
|
26780
|
+
|
|
26781
|
+
result.Finalize();
|
|
26782
|
+
return result;
|
|
26783
|
+
}
|
|
26784
|
+
|
|
26785
|
+
template <>
|
|
26786
|
+
string_t StringCastTZ::Operation(timestamp_t input, Vector &vector) {
|
|
26787
|
+
date_t date_entry;
|
|
26788
|
+
dtime_t time_entry;
|
|
26789
|
+
Timestamp::Convert(input, date_entry, time_entry);
|
|
26790
|
+
|
|
26791
|
+
int32_t date[3], time[4];
|
|
26792
|
+
Date::Convert(date_entry, date[0], date[1], date[2]);
|
|
26793
|
+
Time::Convert(time_entry, time[0], time[1], time[2], time[3]);
|
|
26794
|
+
|
|
26795
|
+
// format for timestamptz is DATE TIME+00 (separated by space)
|
|
26796
|
+
idx_t year_length;
|
|
26797
|
+
bool add_bc;
|
|
26798
|
+
char micro_buffer[6];
|
|
26799
|
+
const idx_t date_length = DateToStringCast::Length(date, year_length, add_bc);
|
|
26800
|
+
const idx_t time_length = TimeToStringCast::Length(time, micro_buffer);
|
|
26801
|
+
const idx_t length = date_length + 1 + time_length + 3;
|
|
26802
|
+
|
|
26803
|
+
string_t result = StringVector::EmptyString(vector, length);
|
|
26804
|
+
auto data = result.GetDataWriteable();
|
|
26805
|
+
|
|
26806
|
+
idx_t pos = 0;
|
|
26807
|
+
DateToStringCast::Format(data + pos, date, year_length, add_bc);
|
|
26808
|
+
pos += date_length;
|
|
26809
|
+
data[pos++] = ' ';
|
|
26810
|
+
TimeToStringCast::Format(data + pos, time_length, time, micro_buffer);
|
|
26811
|
+
pos += time_length;
|
|
26812
|
+
data[pos++] = '+';
|
|
26813
|
+
data[pos++] = '0';
|
|
26814
|
+
data[pos++] = '0';
|
|
26815
|
+
|
|
26816
|
+
result.Finalize();
|
|
26817
|
+
return result;
|
|
26818
|
+
}
|
|
26819
|
+
|
|
26681
26820
|
} // namespace duckdb
|
|
26682
26821
|
//===----------------------------------------------------------------------===//
|
|
26683
26822
|
// DuckDB
|
|
@@ -36113,6 +36252,9 @@ void SetArrowChild(DuckDBArrowArrayChildHolder &child_holder, const LogicalType
|
|
|
36113
36252
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
36114
36253
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
36115
36254
|
case LogicalTypeId::TIME:
|
|
36255
|
+
case LogicalTypeId::DATE_TZ:
|
|
36256
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
36257
|
+
case LogicalTypeId::TIME_TZ:
|
|
36116
36258
|
child_holder.vector = make_unique<Vector>(data);
|
|
36117
36259
|
child.n_buffers = 2;
|
|
36118
36260
|
child.buffers[1] = (void *)FlatVector::GetData(*child_holder.vector);
|
|
@@ -37881,8 +38023,8 @@ enum class DatePartSpecifier : uint8_t {
|
|
|
37881
38023
|
YEARWEEK
|
|
37882
38024
|
};
|
|
37883
38025
|
|
|
37884
|
-
bool TryGetDatePartSpecifier(const string &specifier, DatePartSpecifier &result);
|
|
37885
|
-
DatePartSpecifier GetDatePartSpecifier(const string &specifier);
|
|
38026
|
+
DUCKDB_API bool TryGetDatePartSpecifier(const string &specifier, DatePartSpecifier &result);
|
|
38027
|
+
DUCKDB_API DatePartSpecifier GetDatePartSpecifier(const string &specifier);
|
|
37886
38028
|
|
|
37887
38029
|
} // namespace duckdb
|
|
37888
38030
|
|
|
@@ -39108,6 +39250,28 @@ string Time::ToString(dtime_t time) {
|
|
|
39108
39250
|
return string(buffer.get(), length);
|
|
39109
39251
|
}
|
|
39110
39252
|
|
|
39253
|
+
string Time::ToUTCOffset(int hour_offset, int minute_offset) {
|
|
39254
|
+
dtime_t time((hour_offset * Interval::MINS_PER_HOUR + minute_offset) * Interval::MICROS_PER_MINUTE);
|
|
39255
|
+
|
|
39256
|
+
char buffer[1 + 2 + 1 + 2];
|
|
39257
|
+
idx_t length = 0;
|
|
39258
|
+
buffer[length++] = (time.micros < 0 ? '-' : '+');
|
|
39259
|
+
time.micros = std::abs(time.micros);
|
|
39260
|
+
|
|
39261
|
+
int32_t time_units[4];
|
|
39262
|
+
Time::Convert(time, time_units[0], time_units[1], time_units[2], time_units[3]);
|
|
39263
|
+
|
|
39264
|
+
TimeToStringCast::FormatTwoDigits(buffer + length, time_units[0]);
|
|
39265
|
+
length += 2;
|
|
39266
|
+
if (time_units[1]) {
|
|
39267
|
+
buffer[length++] = ':';
|
|
39268
|
+
TimeToStringCast::FormatTwoDigits(buffer + length, time_units[1]);
|
|
39269
|
+
length += 2;
|
|
39270
|
+
}
|
|
39271
|
+
|
|
39272
|
+
return string(buffer, length);
|
|
39273
|
+
}
|
|
39274
|
+
|
|
39111
39275
|
dtime_t Time::FromTime(int32_t hour, int32_t minute, int32_t second, int32_t microseconds) {
|
|
39112
39276
|
int64_t result;
|
|
39113
39277
|
result = hour; // hours
|
|
@@ -39774,6 +39938,12 @@ Value Value::MinimumValue(const LogicalType &type) {
|
|
|
39774
39938
|
return Value::TimestampMs(timestamp_t(NumericLimits<int64_t>::Minimum()));
|
|
39775
39939
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
39776
39940
|
return Value::TimestampNs(timestamp_t(NumericLimits<int64_t>::Minimum()));
|
|
39941
|
+
case LogicalTypeId::DATE_TZ:
|
|
39942
|
+
return Value::DATETZ(date_t(NumericLimits<int32_t>::Minimum()));
|
|
39943
|
+
case LogicalTypeId::TIME_TZ:
|
|
39944
|
+
return Value::TIMETZ(dtime_t(0));
|
|
39945
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
39946
|
+
return Value::TIMESTAMPTZ(timestamp_t(NumericLimits<int64_t>::Minimum()));
|
|
39777
39947
|
case LogicalTypeId::FLOAT:
|
|
39778
39948
|
return Value::FLOAT(NumericLimits<float>::Minimum());
|
|
39779
39949
|
case LogicalTypeId::DOUBLE:
|
|
@@ -39859,6 +40029,12 @@ Value Value::MaximumValue(const LogicalType &type) {
|
|
|
39859
40029
|
return Value::TimestampNs(timestamp_t(NumericLimits<int64_t>::Maximum()));
|
|
39860
40030
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
39861
40031
|
return Value::TimestampSec(timestamp_t(NumericLimits<int64_t>::Maximum()));
|
|
40032
|
+
case LogicalTypeId::DATE_TZ:
|
|
40033
|
+
return Value::DATETZ(date_t(NumericLimits<int32_t>::Maximum()));
|
|
40034
|
+
case LogicalTypeId::TIME_TZ:
|
|
40035
|
+
return Value::TIMETZ(dtime_t(Interval::SECS_PER_DAY * Interval::MICROS_PER_SEC));
|
|
40036
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
40037
|
+
return Value::TIMESTAMPTZ(timestamp_t(NumericLimits<int64_t>::Maximum()));
|
|
39862
40038
|
case LogicalTypeId::FLOAT:
|
|
39863
40039
|
return Value::FLOAT(NumericLimits<float>::Maximum());
|
|
39864
40040
|
case LogicalTypeId::DOUBLE:
|
|
@@ -40091,6 +40267,13 @@ Value Value::DATE(date_t value) {
|
|
|
40091
40267
|
return result;
|
|
40092
40268
|
}
|
|
40093
40269
|
|
|
40270
|
+
Value Value::DATETZ(date_t value) {
|
|
40271
|
+
Value result(LogicalType::DATE_TZ);
|
|
40272
|
+
result.value_.date = value;
|
|
40273
|
+
result.is_null = false;
|
|
40274
|
+
return result;
|
|
40275
|
+
}
|
|
40276
|
+
|
|
40094
40277
|
Value Value::DATE(int32_t year, int32_t month, int32_t day) {
|
|
40095
40278
|
return Value::DATE(Date::FromDate(year, month, day));
|
|
40096
40279
|
}
|
|
@@ -40102,6 +40285,13 @@ Value Value::TIME(dtime_t value) {
|
|
|
40102
40285
|
return result;
|
|
40103
40286
|
}
|
|
40104
40287
|
|
|
40288
|
+
Value Value::TIMETZ(dtime_t value) {
|
|
40289
|
+
Value result(LogicalType::TIME_TZ);
|
|
40290
|
+
result.value_.time = value;
|
|
40291
|
+
result.is_null = false;
|
|
40292
|
+
return result;
|
|
40293
|
+
}
|
|
40294
|
+
|
|
40105
40295
|
Value Value::TIME(int32_t hour, int32_t min, int32_t sec, int32_t micros) {
|
|
40106
40296
|
return Value::TIME(Time::FromTime(hour, min, sec, micros));
|
|
40107
40297
|
}
|
|
@@ -40113,6 +40303,13 @@ Value Value::TIMESTAMP(timestamp_t value) {
|
|
|
40113
40303
|
return result;
|
|
40114
40304
|
}
|
|
40115
40305
|
|
|
40306
|
+
Value Value::TIMESTAMPTZ(timestamp_t value) {
|
|
40307
|
+
Value result(LogicalType::TIMESTAMP_TZ);
|
|
40308
|
+
result.value_.timestamp = value;
|
|
40309
|
+
result.is_null = false;
|
|
40310
|
+
return result;
|
|
40311
|
+
}
|
|
40312
|
+
|
|
40116
40313
|
Value Value::TimestampNs(timestamp_t timestamp) {
|
|
40117
40314
|
Value result(LogicalType::TIMESTAMP_NS);
|
|
40118
40315
|
result.value_.timestamp = timestamp;
|
|
@@ -40367,10 +40564,13 @@ T Value::GetValueInternal() const {
|
|
|
40367
40564
|
case LogicalTypeId::UUID:
|
|
40368
40565
|
return Cast::Operation<hugeint_t, T>(value_.hugeint);
|
|
40369
40566
|
case LogicalTypeId::DATE:
|
|
40567
|
+
case LogicalTypeId::DATE_TZ:
|
|
40370
40568
|
return Cast::Operation<date_t, T>(value_.date);
|
|
40371
40569
|
case LogicalTypeId::TIME:
|
|
40570
|
+
case LogicalTypeId::TIME_TZ:
|
|
40372
40571
|
return Cast::Operation<dtime_t, T>(value_.time);
|
|
40373
40572
|
case LogicalTypeId::TIMESTAMP:
|
|
40573
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
40374
40574
|
return Cast::Operation<timestamp_t, T>(value_.timestamp);
|
|
40375
40575
|
case LogicalTypeId::UTINYINT:
|
|
40376
40576
|
return Cast::Operation<uint8_t, T>(value_.utinyint);
|
|
@@ -40419,12 +40619,18 @@ int32_t Value::GetValue() const {
|
|
|
40419
40619
|
}
|
|
40420
40620
|
template <>
|
|
40421
40621
|
int64_t Value::GetValue() const {
|
|
40422
|
-
|
|
40423
|
-
|
|
40424
|
-
|
|
40622
|
+
switch (type_.id()) {
|
|
40623
|
+
case LogicalTypeId::TIMESTAMP:
|
|
40624
|
+
case LogicalTypeId::TIMESTAMP_SEC:
|
|
40625
|
+
case LogicalTypeId::TIMESTAMP_NS:
|
|
40626
|
+
case LogicalTypeId::TIMESTAMP_MS:
|
|
40627
|
+
case LogicalTypeId::TIME:
|
|
40628
|
+
case LogicalTypeId::TIME_TZ:
|
|
40629
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
40425
40630
|
return value_.bigint;
|
|
40631
|
+
default:
|
|
40632
|
+
return GetValueInternal<int64_t>();
|
|
40426
40633
|
}
|
|
40427
|
-
return GetValueInternal<int64_t>();
|
|
40428
40634
|
}
|
|
40429
40635
|
template <>
|
|
40430
40636
|
hugeint_t Value::GetValue() const {
|
|
@@ -40702,6 +40908,12 @@ string Value::ToString() const {
|
|
|
40702
40908
|
return Time::ToString(value_.time);
|
|
40703
40909
|
case LogicalTypeId::TIMESTAMP:
|
|
40704
40910
|
return Timestamp::ToString(value_.timestamp);
|
|
40911
|
+
case LogicalTypeId::DATE_TZ:
|
|
40912
|
+
return Date::ToString(value_.date) + Time::ToUTCOffset(0, 0);
|
|
40913
|
+
case LogicalTypeId::TIME_TZ:
|
|
40914
|
+
return Time::ToString(value_.time) + Time::ToUTCOffset(0, 0);
|
|
40915
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
40916
|
+
return Timestamp::ToString(value_.timestamp) + Time::ToUTCOffset(0, 0);
|
|
40705
40917
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
40706
40918
|
return Timestamp::ToString(Timestamp::FromEpochSeconds(value_.timestamp.value));
|
|
40707
40919
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
@@ -41376,6 +41588,7 @@ void Vector::SetValue(idx_t index, const Value &val) {
|
|
|
41376
41588
|
((int16_t *)data)[index] = val.value_.smallint;
|
|
41377
41589
|
break;
|
|
41378
41590
|
case LogicalTypeId::DATE:
|
|
41591
|
+
case LogicalTypeId::DATE_TZ:
|
|
41379
41592
|
case LogicalTypeId::INTEGER:
|
|
41380
41593
|
((int32_t *)data)[index] = val.value_.integer;
|
|
41381
41594
|
break;
|
|
@@ -41386,6 +41599,8 @@ void Vector::SetValue(idx_t index, const Value &val) {
|
|
|
41386
41599
|
case LogicalTypeId::HASH:
|
|
41387
41600
|
case LogicalTypeId::TIME:
|
|
41388
41601
|
case LogicalTypeId::BIGINT:
|
|
41602
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
41603
|
+
case LogicalTypeId::TIME_TZ:
|
|
41389
41604
|
((int64_t *)data)[index] = val.value_.bigint;
|
|
41390
41605
|
break;
|
|
41391
41606
|
case LogicalTypeId::UTINYINT:
|
|
@@ -41528,8 +41743,12 @@ Value Vector::GetValue(idx_t index) const {
|
|
|
41528
41743
|
return Value::INTEGER(((int32_t *)data)[index]);
|
|
41529
41744
|
case LogicalTypeId::DATE:
|
|
41530
41745
|
return Value::DATE(((date_t *)data)[index]);
|
|
41746
|
+
case LogicalTypeId::DATE_TZ:
|
|
41747
|
+
return Value::DATETZ(((date_t *)data)[index]);
|
|
41531
41748
|
case LogicalTypeId::TIME:
|
|
41532
41749
|
return Value::TIME(((dtime_t *)data)[index]);
|
|
41750
|
+
case LogicalTypeId::TIME_TZ:
|
|
41751
|
+
return Value::TIMETZ(((dtime_t *)data)[index]);
|
|
41533
41752
|
case LogicalTypeId::BIGINT:
|
|
41534
41753
|
return Value::BIGINT(((int64_t *)data)[index]);
|
|
41535
41754
|
case LogicalTypeId::UTINYINT:
|
|
@@ -41548,6 +41767,8 @@ Value Vector::GetValue(idx_t index) const {
|
|
|
41548
41767
|
return Value::TimestampMs(((timestamp_t *)data)[index]);
|
|
41549
41768
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
41550
41769
|
return Value::TimestampSec(((timestamp_t *)data)[index]);
|
|
41770
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
41771
|
+
return Value::TIMESTAMPTZ(((timestamp_t *)data)[index]);
|
|
41551
41772
|
case LogicalTypeId::HUGEINT:
|
|
41552
41773
|
return Value::HUGEINT(((hugeint_t *)data)[index]);
|
|
41553
41774
|
case LogicalTypeId::UUID:
|
|
@@ -42121,7 +42342,7 @@ void Vector::Verify(const SelectionVector &sel, idx_t count) {
|
|
|
42121
42342
|
|
|
42122
42343
|
if (GetType().InternalType() == PhysicalType::STRUCT) {
|
|
42123
42344
|
auto &child_types = StructType::GetChildTypes(GetType());
|
|
42124
|
-
D_ASSERT(child_types.
|
|
42345
|
+
D_ASSERT(!child_types.empty());
|
|
42125
42346
|
if (GetVectorType() == VectorType::FLAT_VECTOR || GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
42126
42347
|
// create a selection vector of the non-null entries of the struct vector
|
|
42127
42348
|
auto &children = StructVector::GetEntries(*this);
|
|
@@ -42551,13 +42772,16 @@ vector<idx_t> ListVector::Search(Vector &list, Value &key, idx_t row) {
|
|
|
42551
42772
|
entry.length);
|
|
42552
42773
|
break;
|
|
42553
42774
|
case LogicalTypeId::DATE:
|
|
42775
|
+
case LogicalTypeId::DATE_TZ:
|
|
42554
42776
|
::duckdb::TemplatedSearchInMap<date_t>(list, key.value_.date, offsets, key.is_null, entry.offset, entry.length);
|
|
42555
42777
|
break;
|
|
42556
42778
|
case LogicalTypeId::TIME:
|
|
42779
|
+
case LogicalTypeId::TIME_TZ:
|
|
42557
42780
|
::duckdb::TemplatedSearchInMap<dtime_t>(list, key.value_.time, offsets, key.is_null, entry.offset,
|
|
42558
42781
|
entry.length);
|
|
42559
42782
|
break;
|
|
42560
42783
|
case LogicalTypeId::TIMESTAMP:
|
|
42784
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
42561
42785
|
::duckdb::TemplatedSearchInMap<timestamp_t>(list, key.value_.timestamp, offsets, key.is_null, entry.offset,
|
|
42562
42786
|
entry.length);
|
|
42563
42787
|
break;
|
|
@@ -43354,6 +43578,7 @@ PhysicalType LogicalType::GetInternalType() {
|
|
|
43354
43578
|
return PhysicalType::UINT16;
|
|
43355
43579
|
case LogicalTypeId::SQLNULL:
|
|
43356
43580
|
case LogicalTypeId::DATE:
|
|
43581
|
+
case LogicalTypeId::DATE_TZ:
|
|
43357
43582
|
case LogicalTypeId::INTEGER:
|
|
43358
43583
|
return PhysicalType::INT32;
|
|
43359
43584
|
case LogicalTypeId::UINTEGER:
|
|
@@ -43364,6 +43589,8 @@ PhysicalType LogicalType::GetInternalType() {
|
|
|
43364
43589
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
43365
43590
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
43366
43591
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
43592
|
+
case LogicalTypeId::TIME_TZ:
|
|
43593
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
43367
43594
|
return PhysicalType::INT64;
|
|
43368
43595
|
case LogicalTypeId::UBIGINT:
|
|
43369
43596
|
return PhysicalType::UINT64;
|
|
@@ -43457,6 +43684,11 @@ constexpr const LogicalTypeId LogicalType::TIMESTAMP_NS;
|
|
|
43457
43684
|
constexpr const LogicalTypeId LogicalType::TIMESTAMP_S;
|
|
43458
43685
|
|
|
43459
43686
|
constexpr const LogicalTypeId LogicalType::TIME;
|
|
43687
|
+
|
|
43688
|
+
constexpr const LogicalTypeId LogicalType::DATE_TZ;
|
|
43689
|
+
constexpr const LogicalTypeId LogicalType::TIME_TZ;
|
|
43690
|
+
constexpr const LogicalTypeId LogicalType::TIMESTAMP_TZ;
|
|
43691
|
+
|
|
43460
43692
|
constexpr const LogicalTypeId LogicalType::HASH;
|
|
43461
43693
|
constexpr const LogicalTypeId LogicalType::POINTER;
|
|
43462
43694
|
|
|
@@ -43485,7 +43717,8 @@ const vector<LogicalType> LogicalType::ALL_TYPES = {
|
|
|
43485
43717
|
LogicalType::FLOAT, LogicalType::VARCHAR, LogicalType::BLOB, LogicalType::INTERVAL,
|
|
43486
43718
|
LogicalType::HUGEINT, LogicalTypeId::DECIMAL, LogicalType::UTINYINT, LogicalType::USMALLINT,
|
|
43487
43719
|
LogicalType::UINTEGER, LogicalType::UBIGINT, LogicalType::TIME, LogicalTypeId::LIST,
|
|
43488
|
-
LogicalTypeId::STRUCT,
|
|
43720
|
+
LogicalTypeId::STRUCT, LogicalType::DATE_TZ, LogicalType::TIME_TZ, LogicalType::TIMESTAMP_TZ,
|
|
43721
|
+
LogicalTypeId::MAP, LogicalType::UUID};
|
|
43489
43722
|
|
|
43490
43723
|
const LogicalType LOGICAL_ROW_TYPE = LogicalType::BIGINT;
|
|
43491
43724
|
const PhysicalType ROW_TYPE = PhysicalType::INT64;
|
|
@@ -43667,6 +43900,12 @@ string LogicalTypeIdToString(LogicalTypeId id) {
|
|
|
43667
43900
|
return "TIMESTAMP (NS)";
|
|
43668
43901
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
43669
43902
|
return "TIMESTAMP (SEC)";
|
|
43903
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
43904
|
+
return "TIMESTAMP WITH TIME ZONE";
|
|
43905
|
+
case LogicalTypeId::TIME_TZ:
|
|
43906
|
+
return "TIME WITH TIME ZONE";
|
|
43907
|
+
case LogicalTypeId::DATE_TZ:
|
|
43908
|
+
return "DATE WITH TIME ZONE";
|
|
43670
43909
|
case LogicalTypeId::FLOAT:
|
|
43671
43910
|
return "FLOAT";
|
|
43672
43911
|
case LogicalTypeId::DOUBLE:
|
|
@@ -43824,6 +44063,12 @@ LogicalTypeId TransformStringToLogicalType(const string &str) {
|
|
|
43824
44063
|
return LogicalTypeId::UINTEGER;
|
|
43825
44064
|
} else if (lower_str == "ubigint" || lower_str == "uint64") {
|
|
43826
44065
|
return LogicalTypeId::UBIGINT;
|
|
44066
|
+
} else if (lower_str == "timestamptz") {
|
|
44067
|
+
return LogicalTypeId::TIMESTAMP_TZ;
|
|
44068
|
+
} else if (lower_str == "timetz") {
|
|
44069
|
+
return LogicalTypeId::TIME_TZ;
|
|
44070
|
+
} else if (lower_str == "datetz") {
|
|
44071
|
+
return LogicalTypeId::DATE_TZ;
|
|
43827
44072
|
} else {
|
|
43828
44073
|
// This is a User Type, at this point we don't know if its one of the User Defined Types or an error
|
|
43829
44074
|
// It is checked in the binder
|
|
@@ -47281,12 +47526,15 @@ static bool StringCastSwitch(Vector &source, Vector &result, idx_t count, bool s
|
|
|
47281
47526
|
// now switch on the result type
|
|
47282
47527
|
switch (result.GetType().id()) {
|
|
47283
47528
|
case LogicalTypeId::DATE:
|
|
47529
|
+
case LogicalTypeId::DATE_TZ:
|
|
47284
47530
|
return VectorTryCastErrorLoop<string_t, date_t, duckdb::TryCastErrorMessage>(source, result, count, strict,
|
|
47285
47531
|
error_message);
|
|
47286
47532
|
case LogicalTypeId::TIME:
|
|
47533
|
+
case LogicalTypeId::TIME_TZ:
|
|
47287
47534
|
return VectorTryCastErrorLoop<string_t, dtime_t, duckdb::TryCastErrorMessage>(source, result, count, strict,
|
|
47288
47535
|
error_message);
|
|
47289
47536
|
case LogicalTypeId::TIMESTAMP:
|
|
47537
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
47290
47538
|
return VectorTryCastErrorLoop<string_t, timestamp_t, duckdb::TryCastErrorMessage>(source, result, count, strict,
|
|
47291
47539
|
error_message);
|
|
47292
47540
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
@@ -47319,8 +47567,34 @@ static bool DateCastSwitch(Vector &source, Vector &result, idx_t count, string *
|
|
|
47319
47567
|
VectorStringCast<date_t, duckdb::StringCast>(source, result, count);
|
|
47320
47568
|
return true;
|
|
47321
47569
|
case LogicalTypeId::TIMESTAMP:
|
|
47570
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
47322
47571
|
// date to timestamp
|
|
47323
47572
|
return VectorTryCastLoop<date_t, timestamp_t, duckdb::TryCast>(source, result, count, error_message);
|
|
47573
|
+
case LogicalTypeId::DATE_TZ:
|
|
47574
|
+
// date to date with time zone
|
|
47575
|
+
UnaryExecutor::Execute<date_t, date_t, duckdb::Cast>(source, result, count);
|
|
47576
|
+
return true;
|
|
47577
|
+
default:
|
|
47578
|
+
return TryVectorNullCast(source, result, count, error_message);
|
|
47579
|
+
}
|
|
47580
|
+
}
|
|
47581
|
+
|
|
47582
|
+
static bool DateTzCastSwitch(Vector &source, Vector &result, idx_t count, string *error_message) {
|
|
47583
|
+
// now switch on the result type
|
|
47584
|
+
switch (result.GetType().id()) {
|
|
47585
|
+
case LogicalTypeId::VARCHAR:
|
|
47586
|
+
// date with time zone to varchar
|
|
47587
|
+
VectorStringCast<date_t, duckdb::StringCastTZ>(source, result, count);
|
|
47588
|
+
return true;
|
|
47589
|
+
case LogicalTypeId::TIMESTAMP:
|
|
47590
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
47591
|
+
// date with time zone to timestamp
|
|
47592
|
+
return VectorTryCastLoop<date_t, timestamp_t, duckdb::TryCast>(source, result, count, error_message);
|
|
47593
|
+
case LogicalTypeId::DATE:
|
|
47594
|
+
case LogicalTypeId::DATE_TZ:
|
|
47595
|
+
// date with time zone to date
|
|
47596
|
+
UnaryExecutor::Execute<date_t, date_t, duckdb::Cast>(source, result, count);
|
|
47597
|
+
return true;
|
|
47324
47598
|
default:
|
|
47325
47599
|
return TryVectorNullCast(source, result, count, error_message);
|
|
47326
47600
|
}
|
|
@@ -47333,6 +47607,26 @@ static bool TimeCastSwitch(Vector &source, Vector &result, idx_t count, string *
|
|
|
47333
47607
|
// time to varchar
|
|
47334
47608
|
VectorStringCast<dtime_t, duckdb::StringCast>(source, result, count);
|
|
47335
47609
|
return true;
|
|
47610
|
+
case LogicalTypeId::TIME_TZ:
|
|
47611
|
+
// time to time with time zone
|
|
47612
|
+
UnaryExecutor::Execute<dtime_t, dtime_t, duckdb::Cast>(source, result, count);
|
|
47613
|
+
return true;
|
|
47614
|
+
default:
|
|
47615
|
+
return TryVectorNullCast(source, result, count, error_message);
|
|
47616
|
+
}
|
|
47617
|
+
}
|
|
47618
|
+
|
|
47619
|
+
static bool TimeTzCastSwitch(Vector &source, Vector &result, idx_t count, string *error_message) {
|
|
47620
|
+
// now switch on the result type
|
|
47621
|
+
switch (result.GetType().id()) {
|
|
47622
|
+
case LogicalTypeId::VARCHAR:
|
|
47623
|
+
// time with time zone to varchar
|
|
47624
|
+
VectorStringCast<dtime_t, duckdb::StringCastTZ>(source, result, count);
|
|
47625
|
+
return true;
|
|
47626
|
+
case LogicalTypeId::TIME:
|
|
47627
|
+
// time with time zone to time
|
|
47628
|
+
UnaryExecutor::Execute<dtime_t, dtime_t, duckdb::Cast>(source, result, count);
|
|
47629
|
+
return true;
|
|
47336
47630
|
default:
|
|
47337
47631
|
return TryVectorNullCast(source, result, count, error_message);
|
|
47338
47632
|
}
|
|
@@ -47346,13 +47640,19 @@ static bool TimestampCastSwitch(Vector &source, Vector &result, idx_t count, str
|
|
|
47346
47640
|
VectorStringCast<timestamp_t, duckdb::StringCast>(source, result, count);
|
|
47347
47641
|
break;
|
|
47348
47642
|
case LogicalTypeId::DATE:
|
|
47643
|
+
case LogicalTypeId::DATE_TZ:
|
|
47349
47644
|
// timestamp to date
|
|
47350
47645
|
UnaryExecutor::Execute<timestamp_t, date_t, duckdb::Cast>(source, result, count);
|
|
47351
47646
|
break;
|
|
47352
47647
|
case LogicalTypeId::TIME:
|
|
47648
|
+
case LogicalTypeId::TIME_TZ:
|
|
47353
47649
|
// timestamp to time
|
|
47354
47650
|
UnaryExecutor::Execute<timestamp_t, dtime_t, duckdb::Cast>(source, result, count);
|
|
47355
47651
|
break;
|
|
47652
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
47653
|
+
// timestamp (us) to timestamp with time zone
|
|
47654
|
+
UnaryExecutor::Execute<timestamp_t, timestamp_t, duckdb::Cast>(source, result, count);
|
|
47655
|
+
break;
|
|
47356
47656
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
47357
47657
|
// timestamp (us) to timestamp (ns)
|
|
47358
47658
|
UnaryExecutor::Execute<timestamp_t, timestamp_t, duckdb::CastTimestampUsToNs>(source, result, count);
|
|
@@ -47371,6 +47671,33 @@ static bool TimestampCastSwitch(Vector &source, Vector &result, idx_t count, str
|
|
|
47371
47671
|
return true;
|
|
47372
47672
|
}
|
|
47373
47673
|
|
|
47674
|
+
static bool TimestampTzCastSwitch(Vector &source, Vector &result, idx_t count, string *error_message) {
|
|
47675
|
+
// now switch on the result type
|
|
47676
|
+
switch (result.GetType().id()) {
|
|
47677
|
+
case LogicalTypeId::VARCHAR:
|
|
47678
|
+
// timestamp with time zone to varchar
|
|
47679
|
+
VectorStringCast<timestamp_t, duckdb::StringCastTZ>(source, result, count);
|
|
47680
|
+
break;
|
|
47681
|
+
case LogicalTypeId::DATE:
|
|
47682
|
+
case LogicalTypeId::DATE_TZ:
|
|
47683
|
+
// timestamp with time zone to date
|
|
47684
|
+
UnaryExecutor::Execute<timestamp_t, date_t, duckdb::Cast>(source, result, count);
|
|
47685
|
+
break;
|
|
47686
|
+
case LogicalTypeId::TIME:
|
|
47687
|
+
case LogicalTypeId::TIME_TZ:
|
|
47688
|
+
// timestamp with time zone to time
|
|
47689
|
+
UnaryExecutor::Execute<timestamp_t, dtime_t, duckdb::Cast>(source, result, count);
|
|
47690
|
+
break;
|
|
47691
|
+
case LogicalTypeId::TIMESTAMP:
|
|
47692
|
+
// timestamp with time zone to timestamp (us)
|
|
47693
|
+
UnaryExecutor::Execute<timestamp_t, timestamp_t, duckdb::Cast>(source, result, count);
|
|
47694
|
+
break;
|
|
47695
|
+
default:
|
|
47696
|
+
return TryVectorNullCast(source, result, count, error_message);
|
|
47697
|
+
}
|
|
47698
|
+
return true;
|
|
47699
|
+
}
|
|
47700
|
+
|
|
47374
47701
|
static bool TimestampNsCastSwitch(Vector &source, Vector &result, idx_t count, string *error_message) {
|
|
47375
47702
|
// now switch on the result type
|
|
47376
47703
|
switch (result.GetType().id()) {
|
|
@@ -47719,10 +48046,16 @@ bool VectorOperations::TryCast(Vector &source, Vector &result, idx_t count, stri
|
|
|
47719
48046
|
return NumericCastSwitch<double>(source, result, count, error_message);
|
|
47720
48047
|
case LogicalTypeId::DATE:
|
|
47721
48048
|
return DateCastSwitch(source, result, count, error_message);
|
|
48049
|
+
case LogicalTypeId::DATE_TZ:
|
|
48050
|
+
return DateTzCastSwitch(source, result, count, error_message);
|
|
47722
48051
|
case LogicalTypeId::TIME:
|
|
47723
48052
|
return TimeCastSwitch(source, result, count, error_message);
|
|
48053
|
+
case LogicalTypeId::TIME_TZ:
|
|
48054
|
+
return TimeTzCastSwitch(source, result, count, error_message);
|
|
47724
48055
|
case LogicalTypeId::TIMESTAMP:
|
|
47725
48056
|
return TimestampCastSwitch(source, result, count, error_message);
|
|
48057
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
48058
|
+
return TimestampTzCastSwitch(source, result, count, error_message);
|
|
47726
48059
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
47727
48060
|
return TimestampNsCastSwitch(source, result, count, error_message);
|
|
47728
48061
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
@@ -73414,6 +73747,12 @@ struct ApproxCountDistinctFunctionString : ApproxCountDistinctFunctionBase {
|
|
|
73414
73747
|
}
|
|
73415
73748
|
};
|
|
73416
73749
|
|
|
73750
|
+
template <typename INPUT_TYPE, typename RESULT_TYPE>
|
|
73751
|
+
AggregateFunction GetApproxCountDistinctFunction(const LogicalType &input_type, const LogicalType &result_type) {
|
|
73752
|
+
return AggregateFunction::UnaryAggregateDestructor<ApproxDistinctCountState, INPUT_TYPE, RESULT_TYPE,
|
|
73753
|
+
ApproxCountDistinctFunction>(input_type, result_type);
|
|
73754
|
+
}
|
|
73755
|
+
|
|
73417
73756
|
AggregateFunction GetApproxCountDistinctFunction(PhysicalType type) {
|
|
73418
73757
|
switch (type) {
|
|
73419
73758
|
case PhysicalType::UINT16:
|
|
@@ -73469,9 +73808,10 @@ void ApproxCountDistinctFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
73469
73808
|
approx_count.AddFunction(GetApproxCountDistinctFunction(PhysicalType::INT64));
|
|
73470
73809
|
approx_count.AddFunction(GetApproxCountDistinctFunction(PhysicalType::DOUBLE));
|
|
73471
73810
|
approx_count.AddFunction(GetApproxCountDistinctFunction(PhysicalType::VARCHAR));
|
|
73472
|
-
approx_count.AddFunction(
|
|
73473
|
-
|
|
73474
|
-
|
|
73811
|
+
approx_count.AddFunction(
|
|
73812
|
+
GetApproxCountDistinctFunction<int64_t, int64_t>(LogicalType::TIMESTAMP, LogicalType::BIGINT));
|
|
73813
|
+
approx_count.AddFunction(
|
|
73814
|
+
GetApproxCountDistinctFunction<int64_t, int64_t>(LogicalType::TIMESTAMP_TZ, LogicalType::BIGINT));
|
|
73475
73815
|
set.AddFunction(approx_count);
|
|
73476
73816
|
}
|
|
73477
73817
|
|
|
@@ -73602,6 +73942,12 @@ AggregateFunction GetArgMinMaxFunctionArg2(LogicalTypeId arg_2, const LogicalTyp
|
|
|
73602
73942
|
case LogicalTypeId::TIMESTAMP:
|
|
73603
73943
|
return AggregateFunction::BinaryAggregate<ArgMinMaxState<T, timestamp_t>, T, timestamp_t, T, OP>(
|
|
73604
73944
|
arg, LogicalType::TIMESTAMP, arg);
|
|
73945
|
+
case LogicalTypeId::DATE_TZ:
|
|
73946
|
+
return AggregateFunction::BinaryAggregate<ArgMinMaxState<T, date_t>, T, date_t, T, OP>(
|
|
73947
|
+
arg, LogicalType::DATE_TZ, arg);
|
|
73948
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
73949
|
+
return AggregateFunction::BinaryAggregate<ArgMinMaxState<T, timestamp_t>, T, timestamp_t, T, OP>(
|
|
73950
|
+
arg, LogicalType::TIMESTAMP_TZ, arg);
|
|
73605
73951
|
case LogicalTypeId::BLOB:
|
|
73606
73952
|
return AggregateFunction::BinaryAggregate<ArgMinMaxState<T, string_t>, T, string_t, T, OP>(
|
|
73607
73953
|
arg, LogicalType::BLOB, arg);
|
|
@@ -73620,6 +73966,8 @@ void GetArgMinMaxFunction(LogicalTypeId arg_1, AggregateFunctionSet &fun) {
|
|
|
73620
73966
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int32_t>(LogicalTypeId::VARCHAR, LogicalType::INTEGER));
|
|
73621
73967
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int32_t>(LogicalTypeId::DATE, LogicalType::INTEGER));
|
|
73622
73968
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int32_t>(LogicalTypeId::TIMESTAMP, LogicalType::INTEGER));
|
|
73969
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int32_t>(LogicalTypeId::DATE_TZ, LogicalType::INTEGER));
|
|
73970
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int32_t>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::INTEGER));
|
|
73623
73971
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int32_t>(LogicalTypeId::BLOB, LogicalType::INTEGER));
|
|
73624
73972
|
break;
|
|
73625
73973
|
case LogicalTypeId::BIGINT:
|
|
@@ -73629,6 +73977,8 @@ void GetArgMinMaxFunction(LogicalTypeId arg_1, AggregateFunctionSet &fun) {
|
|
|
73629
73977
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int64_t>(LogicalTypeId::VARCHAR, LogicalType::BIGINT));
|
|
73630
73978
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int64_t>(LogicalTypeId::DATE, LogicalType::BIGINT));
|
|
73631
73979
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int64_t>(LogicalTypeId::TIMESTAMP, LogicalType::BIGINT));
|
|
73980
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int64_t>(LogicalTypeId::DATE_TZ, LogicalType::BIGINT));
|
|
73981
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int64_t>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::BIGINT));
|
|
73632
73982
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, int64_t>(LogicalTypeId::BLOB, LogicalType::BIGINT));
|
|
73633
73983
|
break;
|
|
73634
73984
|
case LogicalTypeId::DOUBLE:
|
|
@@ -73638,6 +73988,8 @@ void GetArgMinMaxFunction(LogicalTypeId arg_1, AggregateFunctionSet &fun) {
|
|
|
73638
73988
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, double>(LogicalTypeId::VARCHAR, LogicalType::DOUBLE));
|
|
73639
73989
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, double>(LogicalTypeId::DATE, LogicalType::DOUBLE));
|
|
73640
73990
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, double>(LogicalTypeId::TIMESTAMP, LogicalType::DOUBLE));
|
|
73991
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, double>(LogicalTypeId::DATE_TZ, LogicalType::DOUBLE));
|
|
73992
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, double>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::DOUBLE));
|
|
73641
73993
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, double>(LogicalTypeId::BLOB, LogicalType::DOUBLE));
|
|
73642
73994
|
break;
|
|
73643
73995
|
case LogicalTypeId::VARCHAR:
|
|
@@ -73647,6 +73999,8 @@ void GetArgMinMaxFunction(LogicalTypeId arg_1, AggregateFunctionSet &fun) {
|
|
|
73647
73999
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::VARCHAR, LogicalType::VARCHAR));
|
|
73648
74000
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::DATE, LogicalType::VARCHAR));
|
|
73649
74001
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::TIMESTAMP, LogicalType::VARCHAR));
|
|
74002
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::DATE_TZ, LogicalType::VARCHAR));
|
|
74003
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::VARCHAR));
|
|
73650
74004
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::BLOB, LogicalType::VARCHAR));
|
|
73651
74005
|
break;
|
|
73652
74006
|
case LogicalTypeId::DATE:
|
|
@@ -73656,6 +74010,19 @@ void GetArgMinMaxFunction(LogicalTypeId arg_1, AggregateFunctionSet &fun) {
|
|
|
73656
74010
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::VARCHAR, LogicalType::DATE));
|
|
73657
74011
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::DATE, LogicalType::DATE));
|
|
73658
74012
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::TIMESTAMP, LogicalType::DATE));
|
|
74013
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::DATE_TZ, LogicalType::DATE));
|
|
74014
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::DATE));
|
|
74015
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::BLOB, LogicalType::DATE));
|
|
74016
|
+
break;
|
|
74017
|
+
case LogicalTypeId::DATE_TZ:
|
|
74018
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::INTEGER, LogicalType::DATE_TZ));
|
|
74019
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::BIGINT, LogicalType::DATE_TZ));
|
|
74020
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::DOUBLE, LogicalType::DATE_TZ));
|
|
74021
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::VARCHAR, LogicalType::DATE_TZ));
|
|
74022
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::DATE, LogicalType::DATE_TZ));
|
|
74023
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::TIMESTAMP, LogicalType::DATE_TZ));
|
|
74024
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::DATE_TZ, LogicalType::DATE_TZ));
|
|
74025
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::DATE_TZ));
|
|
73659
74026
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, date_t>(LogicalTypeId::BLOB, LogicalType::DATE));
|
|
73660
74027
|
break;
|
|
73661
74028
|
case LogicalTypeId::TIMESTAMP:
|
|
@@ -73665,8 +74032,22 @@ void GetArgMinMaxFunction(LogicalTypeId arg_1, AggregateFunctionSet &fun) {
|
|
|
73665
74032
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::VARCHAR, LogicalType::TIMESTAMP));
|
|
73666
74033
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::DATE, LogicalType::TIMESTAMP));
|
|
73667
74034
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::TIMESTAMP, LogicalType::TIMESTAMP));
|
|
74035
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::DATE_TZ, LogicalType::TIMESTAMP));
|
|
74036
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::TIMESTAMP));
|
|
73668
74037
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::BLOB, LogicalType::TIMESTAMP));
|
|
73669
74038
|
break;
|
|
74039
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
74040
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::INTEGER, LogicalType::TIMESTAMP_TZ));
|
|
74041
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::BIGINT, LogicalType::TIMESTAMP_TZ));
|
|
74042
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::DOUBLE, LogicalType::TIMESTAMP_TZ));
|
|
74043
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::VARCHAR, LogicalType::TIMESTAMP_TZ));
|
|
74044
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::DATE, LogicalType::TIMESTAMP_TZ));
|
|
74045
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::TIMESTAMP, LogicalType::TIMESTAMP_TZ));
|
|
74046
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::DATE_TZ, LogicalType::TIMESTAMP_TZ));
|
|
74047
|
+
fun.AddFunction(
|
|
74048
|
+
GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::TIMESTAMP_TZ));
|
|
74049
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, timestamp_t>(LogicalTypeId::BLOB, LogicalType::TIMESTAMP_TZ));
|
|
74050
|
+
break;
|
|
73670
74051
|
case LogicalTypeId::BLOB:
|
|
73671
74052
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::INTEGER, LogicalType::BLOB));
|
|
73672
74053
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::BIGINT, LogicalType::BLOB));
|
|
@@ -73674,6 +74055,8 @@ void GetArgMinMaxFunction(LogicalTypeId arg_1, AggregateFunctionSet &fun) {
|
|
|
73674
74055
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::VARCHAR, LogicalType::BLOB));
|
|
73675
74056
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::DATE, LogicalType::BLOB));
|
|
73676
74057
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::TIMESTAMP, LogicalType::BLOB));
|
|
74058
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::DATE_TZ, LogicalType::BLOB));
|
|
74059
|
+
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::TIMESTAMP_TZ, LogicalType::BLOB));
|
|
73677
74060
|
fun.AddFunction(GetArgMinMaxFunctionArg2<OP, string_t>(LogicalTypeId::BLOB, LogicalType::BLOB));
|
|
73678
74061
|
break;
|
|
73679
74062
|
default:
|
|
@@ -73688,6 +74071,8 @@ void ArgMinFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
73688
74071
|
GetArgMinMaxFunction<ArgMinOperation>(LogicalTypeId::VARCHAR, fun);
|
|
73689
74072
|
GetArgMinMaxFunction<ArgMinOperation>(LogicalTypeId::DATE, fun);
|
|
73690
74073
|
GetArgMinMaxFunction<ArgMinOperation>(LogicalTypeId::TIMESTAMP, fun);
|
|
74074
|
+
GetArgMinMaxFunction<ArgMinOperation>(LogicalTypeId::DATE_TZ, fun);
|
|
74075
|
+
GetArgMinMaxFunction<ArgMinOperation>(LogicalTypeId::TIMESTAMP_TZ, fun);
|
|
73691
74076
|
GetArgMinMaxFunction<ArgMinOperation>(LogicalTypeId::BLOB, fun);
|
|
73692
74077
|
set.AddFunction(fun);
|
|
73693
74078
|
|
|
@@ -73708,6 +74093,8 @@ void ArgMaxFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
73708
74093
|
GetArgMinMaxFunction<ArgMaxOperation>(LogicalTypeId::VARCHAR, fun);
|
|
73709
74094
|
GetArgMinMaxFunction<ArgMaxOperation>(LogicalTypeId::DATE, fun);
|
|
73710
74095
|
GetArgMinMaxFunction<ArgMaxOperation>(LogicalTypeId::TIMESTAMP, fun);
|
|
74096
|
+
GetArgMinMaxFunction<ArgMaxOperation>(LogicalTypeId::DATE_TZ, fun);
|
|
74097
|
+
GetArgMinMaxFunction<ArgMaxOperation>(LogicalTypeId::TIMESTAMP_TZ, fun);
|
|
73711
74098
|
GetArgMinMaxFunction<ArgMaxOperation>(LogicalTypeId::BLOB, fun);
|
|
73712
74099
|
set.AddFunction(fun);
|
|
73713
74100
|
|
|
@@ -74274,6 +74661,12 @@ struct EntropyFunctionString : EntropyFunctionBase {
|
|
|
74274
74661
|
}
|
|
74275
74662
|
};
|
|
74276
74663
|
|
|
74664
|
+
template <typename INPUT_TYPE, typename RESULT_TYPE>
|
|
74665
|
+
AggregateFunction GetEntropyFunction(const LogicalType &input_type, const LogicalType &result_type) {
|
|
74666
|
+
return AggregateFunction::UnaryAggregateDestructor<EntropyState<INPUT_TYPE>, INPUT_TYPE, RESULT_TYPE,
|
|
74667
|
+
EntropyFunction>(input_type, result_type);
|
|
74668
|
+
}
|
|
74669
|
+
|
|
74277
74670
|
AggregateFunction GetEntropyFunction(PhysicalType type) {
|
|
74278
74671
|
switch (type) {
|
|
74279
74672
|
case PhysicalType::UINT16:
|
|
@@ -74321,9 +74714,8 @@ void EntropyFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
74321
74714
|
entropy.AddFunction(GetEntropyFunction(PhysicalType::INT64));
|
|
74322
74715
|
entropy.AddFunction(GetEntropyFunction(PhysicalType::DOUBLE));
|
|
74323
74716
|
entropy.AddFunction(GetEntropyFunction(PhysicalType::VARCHAR));
|
|
74324
|
-
entropy.AddFunction(
|
|
74325
|
-
|
|
74326
|
-
LogicalType::TIMESTAMP, LogicalType::DOUBLE));
|
|
74717
|
+
entropy.AddFunction(GetEntropyFunction<int64_t, double>(LogicalType::TIMESTAMP, LogicalType::DOUBLE));
|
|
74718
|
+
entropy.AddFunction(GetEntropyFunction<int64_t, double>(LogicalType::TIMESTAMP_TZ, LogicalType::DOUBLE));
|
|
74327
74719
|
set.AddFunction(entropy);
|
|
74328
74720
|
}
|
|
74329
74721
|
|
|
@@ -74562,10 +74954,13 @@ static AggregateFunction GetFirstFunction(const LogicalType &type) {
|
|
|
74562
74954
|
return GetFirstAggregateTemplated<int16_t, LAST>(type);
|
|
74563
74955
|
case LogicalTypeId::INTEGER:
|
|
74564
74956
|
case LogicalTypeId::DATE:
|
|
74957
|
+
case LogicalTypeId::DATE_TZ:
|
|
74565
74958
|
return GetFirstAggregateTemplated<int32_t, LAST>(type);
|
|
74566
74959
|
case LogicalTypeId::BIGINT:
|
|
74567
74960
|
case LogicalTypeId::TIME:
|
|
74568
74961
|
case LogicalTypeId::TIMESTAMP:
|
|
74962
|
+
case LogicalTypeId::TIME_TZ:
|
|
74963
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
74569
74964
|
return GetFirstAggregateTemplated<int64_t, LAST>(type);
|
|
74570
74965
|
case LogicalTypeId::UTINYINT:
|
|
74571
74966
|
return GetFirstAggregateTemplated<uint8_t, LAST>(type);
|
|
@@ -74767,10 +75162,13 @@ static AggregateFunction GetUnaryAggregate(LogicalType type) {
|
|
|
74767
75162
|
case LogicalTypeId::SMALLINT:
|
|
74768
75163
|
return AggregateFunction::UnaryAggregate<MinMaxState<int16_t>, int16_t, int16_t, OP>(type, type);
|
|
74769
75164
|
case LogicalTypeId::DATE:
|
|
75165
|
+
case LogicalTypeId::DATE_TZ:
|
|
74770
75166
|
case LogicalTypeId::INTEGER:
|
|
74771
75167
|
return AggregateFunction::UnaryAggregate<MinMaxState<int32_t>, int32_t, int32_t, OP>(type, type);
|
|
74772
75168
|
case LogicalTypeId::TIMESTAMP:
|
|
74773
75169
|
case LogicalTypeId::TIME:
|
|
75170
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
75171
|
+
case LogicalTypeId::TIME_TZ:
|
|
74774
75172
|
case LogicalTypeId::BIGINT:
|
|
74775
75173
|
return AggregateFunction::UnaryAggregate<MinMaxState<int64_t>, int64_t, int64_t, OP>(type, type);
|
|
74776
75174
|
case LogicalTypeId::UTINYINT:
|
|
@@ -76979,7 +77377,8 @@ unique_ptr<FunctionData> BindModeDecimal(ClientContext &context, AggregateFuncti
|
|
|
76979
77377
|
}
|
|
76980
77378
|
|
|
76981
77379
|
void ModeFun::RegisterFunction(BuiltinFunctions &set) {
|
|
76982
|
-
const vector<LogicalType> TEMPORAL = {LogicalType::DATE,
|
|
77380
|
+
const vector<LogicalType> TEMPORAL = {LogicalType::DATE, LogicalType::TIMESTAMP, LogicalType::TIME,
|
|
77381
|
+
LogicalType::DATE_TZ, LogicalType::TIMESTAMP_TZ, LogicalType::TIME_TZ,
|
|
76983
77382
|
LogicalType::INTERVAL};
|
|
76984
77383
|
|
|
76985
77384
|
AggregateFunctionSet mode("mode");
|
|
@@ -77600,10 +77999,13 @@ AggregateFunction GetDiscreteQuantileAggregateFunction(const LogicalType &type)
|
|
|
77600
77999
|
break;
|
|
77601
78000
|
|
|
77602
78001
|
case LogicalTypeId::DATE:
|
|
78002
|
+
case LogicalTypeId::DATE_TZ:
|
|
77603
78003
|
return GetTypedDiscreteQuantileAggregateFunction<int32_t, int32_t>(type);
|
|
77604
78004
|
case LogicalTypeId::TIMESTAMP:
|
|
78005
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
77605
78006
|
return GetTypedDiscreteQuantileAggregateFunction<int64_t, int64_t>(type);
|
|
77606
78007
|
case LogicalTypeId::TIME:
|
|
78008
|
+
case LogicalTypeId::TIME_TZ:
|
|
77607
78009
|
return GetTypedDiscreteQuantileAggregateFunction<int64_t, int64_t>(type);
|
|
77608
78010
|
case LogicalTypeId::INTERVAL:
|
|
77609
78011
|
return GetTypedDiscreteQuantileAggregateFunction<interval_t, interval_t>(type);
|
|
@@ -77789,10 +78191,13 @@ AggregateFunction GetDiscreteQuantileListAggregateFunction(const LogicalType &ty
|
|
|
77789
78191
|
break;
|
|
77790
78192
|
|
|
77791
78193
|
case LogicalTypeId::DATE:
|
|
78194
|
+
case LogicalTypeId::DATE_TZ:
|
|
77792
78195
|
return GetTypedDiscreteQuantileListAggregateFunction<date_t, date_t>(type);
|
|
77793
78196
|
case LogicalTypeId::TIMESTAMP:
|
|
78197
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
77794
78198
|
return GetTypedDiscreteQuantileListAggregateFunction<timestamp_t, timestamp_t>(type);
|
|
77795
78199
|
case LogicalTypeId::TIME:
|
|
78200
|
+
case LogicalTypeId::TIME_TZ:
|
|
77796
78201
|
return GetTypedDiscreteQuantileListAggregateFunction<dtime_t, dtime_t>(type);
|
|
77797
78202
|
case LogicalTypeId::INTERVAL:
|
|
77798
78203
|
return GetTypedDiscreteQuantileListAggregateFunction<interval_t, interval_t>(type);
|
|
@@ -77850,8 +78255,10 @@ AggregateFunction GetContinuousQuantileAggregateFunction(const LogicalType &type
|
|
|
77850
78255
|
case LogicalTypeId::DATE:
|
|
77851
78256
|
return GetTypedContinuousQuantileAggregateFunction<date_t, timestamp_t>(type, LogicalType::TIMESTAMP);
|
|
77852
78257
|
case LogicalTypeId::TIMESTAMP:
|
|
78258
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
77853
78259
|
return GetTypedContinuousQuantileAggregateFunction<timestamp_t, timestamp_t>(type, type);
|
|
77854
78260
|
case LogicalTypeId::TIME:
|
|
78261
|
+
case LogicalTypeId::TIME_TZ:
|
|
77855
78262
|
return GetTypedContinuousQuantileAggregateFunction<dtime_t, dtime_t>(type, type);
|
|
77856
78263
|
|
|
77857
78264
|
default:
|
|
@@ -77904,8 +78311,10 @@ AggregateFunction GetContinuousQuantileListAggregateFunction(const LogicalType &
|
|
|
77904
78311
|
case LogicalTypeId::DATE:
|
|
77905
78312
|
return GetTypedContinuousQuantileListAggregateFunction<date_t, timestamp_t>(type, LogicalType::TIMESTAMP);
|
|
77906
78313
|
case LogicalTypeId::TIMESTAMP:
|
|
78314
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
77907
78315
|
return GetTypedContinuousQuantileListAggregateFunction<timestamp_t, timestamp_t>(type, type);
|
|
77908
78316
|
case LogicalTypeId::TIME:
|
|
78317
|
+
case LogicalTypeId::TIME_TZ:
|
|
77909
78318
|
return GetTypedContinuousQuantileListAggregateFunction<dtime_t, dtime_t>(type, type);
|
|
77910
78319
|
|
|
77911
78320
|
default:
|
|
@@ -78116,9 +78525,11 @@ AggregateFunction GetMedianAbsoluteDeviationAggregateFunction(const LogicalType
|
|
|
78116
78525
|
return GetTypedMedianAbsoluteDeviationAggregateFunction<date_t, timestamp_t, interval_t>(type,
|
|
78117
78526
|
LogicalType::INTERVAL);
|
|
78118
78527
|
case LogicalTypeId::TIMESTAMP:
|
|
78528
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
78119
78529
|
return GetTypedMedianAbsoluteDeviationAggregateFunction<timestamp_t, timestamp_t, interval_t>(
|
|
78120
78530
|
type, LogicalType::INTERVAL);
|
|
78121
78531
|
case LogicalTypeId::TIME:
|
|
78532
|
+
case LogicalTypeId::TIME_TZ:
|
|
78122
78533
|
return GetTypedMedianAbsoluteDeviationAggregateFunction<dtime_t, dtime_t, interval_t>(type,
|
|
78123
78534
|
LogicalType::INTERVAL);
|
|
78124
78535
|
|
|
@@ -78211,6 +78622,8 @@ unique_ptr<FunctionData> BindContinuousQuantileDecimalList(ClientContext &contex
|
|
|
78211
78622
|
|
|
78212
78623
|
static bool CanInterpolate(const LogicalType &type) {
|
|
78213
78624
|
switch (type.id()) {
|
|
78625
|
+
case LogicalTypeId::DATE_TZ:
|
|
78626
|
+
// DATE_TZ cannot be interpolated without a time zone
|
|
78214
78627
|
case LogicalTypeId::INTERVAL:
|
|
78215
78628
|
case LogicalTypeId::VARCHAR:
|
|
78216
78629
|
return false;
|
|
@@ -78264,7 +78677,8 @@ void QuantileFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
78264
78677
|
const vector<LogicalType> QUANTILES = {LogicalType::TINYINT, LogicalType::SMALLINT, LogicalType::INTEGER,
|
|
78265
78678
|
LogicalType::BIGINT, LogicalType::HUGEINT, LogicalType::FLOAT,
|
|
78266
78679
|
LogicalType::DOUBLE, LogicalType::DATE, LogicalType::TIMESTAMP,
|
|
78267
|
-
LogicalType::TIME, LogicalType::
|
|
78680
|
+
LogicalType::TIME, LogicalType::DATE_TZ, LogicalType::TIMESTAMP_TZ,
|
|
78681
|
+
LogicalType::TIME_TZ, LogicalType::INTERVAL, LogicalType::VARCHAR};
|
|
78268
78682
|
|
|
78269
78683
|
AggregateFunctionSet median("median");
|
|
78270
78684
|
median.AddFunction(AggregateFunction({LogicalTypeId::DECIMAL}, LogicalTypeId::DECIMAL, nullptr, nullptr, nullptr,
|
|
@@ -78307,8 +78721,9 @@ void QuantileFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
78307
78721
|
mad.AddFunction(AggregateFunction({LogicalTypeId::DECIMAL}, LogicalTypeId::DECIMAL, nullptr, nullptr, nullptr,
|
|
78308
78722
|
nullptr, nullptr, nullptr, BindMedianAbsoluteDeviationDecimal));
|
|
78309
78723
|
|
|
78310
|
-
const vector<LogicalType> MADS = {LogicalType::FLOAT,
|
|
78311
|
-
LogicalType::TIMESTAMP, LogicalType::TIME
|
|
78724
|
+
const vector<LogicalType> MADS = {LogicalType::FLOAT, LogicalType::DOUBLE, LogicalType::DATE,
|
|
78725
|
+
LogicalType::TIMESTAMP, LogicalType::TIME, LogicalType::TIMESTAMP_TZ,
|
|
78726
|
+
LogicalType::TIME_TZ};
|
|
78312
78727
|
for (const auto &type : MADS) {
|
|
78313
78728
|
mad.AddFunction(GetMedianAbsoluteDeviationAggregateFunction(type));
|
|
78314
78729
|
}
|
|
@@ -78827,6 +79242,15 @@ unique_ptr<FunctionData> HistogramBindFunction(ClientContext &context, Aggregate
|
|
|
78827
79242
|
return make_unique<VariableReturnBindData>(function.return_type);
|
|
78828
79243
|
}
|
|
78829
79244
|
|
|
79245
|
+
template <typename T>
|
|
79246
|
+
AggregateFunction GetHistogramFunction(const LogicalType &type) {
|
|
79247
|
+
using STATE_TYPE = HistogramAggState<T>;
|
|
79248
|
+
return AggregateFunction("histogram", {type}, LogicalTypeId::MAP, AggregateFunction::StateSize<STATE_TYPE>,
|
|
79249
|
+
AggregateFunction::StateInitialize<STATE_TYPE, HistogramFunction>,
|
|
79250
|
+
HistogramUpdateFunction<T>, HistogramCombineFunction<T>, HistogramFinalize<T>, nullptr,
|
|
79251
|
+
HistogramBindFunction, AggregateFunction::StateDestroy<STATE_TYPE, HistogramFunction>);
|
|
79252
|
+
}
|
|
79253
|
+
|
|
78830
79254
|
AggregateFunction GetHistogramFunction(PhysicalType type) {
|
|
78831
79255
|
switch (type) {
|
|
78832
79256
|
case PhysicalType::UINT16:
|
|
@@ -78909,12 +79333,8 @@ void HistogramFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
78909
79333
|
fun.AddFunction(GetHistogramFunction(PhysicalType::FLOAT));
|
|
78910
79334
|
fun.AddFunction(GetHistogramFunction(PhysicalType::DOUBLE));
|
|
78911
79335
|
fun.AddFunction(GetHistogramFunction(PhysicalType::VARCHAR));
|
|
78912
|
-
fun.AddFunction(
|
|
78913
|
-
|
|
78914
|
-
AggregateFunction::StateInitialize<HistogramAggState<int64_t>, HistogramFunction>,
|
|
78915
|
-
HistogramUpdateFunction<int64_t>, HistogramCombineFunction<int64_t>,
|
|
78916
|
-
HistogramFinalize<int64_t>, nullptr, HistogramBindFunction,
|
|
78917
|
-
AggregateFunction::StateDestroy<HistogramAggState<int64_t>, HistogramFunction>));
|
|
79336
|
+
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP));
|
|
79337
|
+
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP_TZ));
|
|
78918
79338
|
set.AddFunction(fun);
|
|
78919
79339
|
}
|
|
78920
79340
|
|
|
@@ -85123,14 +85543,14 @@ static void LeastGreatestFunction(DataChunk &args, ExpressionState &state, Vecto
|
|
|
85123
85543
|
result.SetVectorType(result_type);
|
|
85124
85544
|
}
|
|
85125
85545
|
|
|
85546
|
+
template <typename T, class OP>
|
|
85547
|
+
ScalarFunction GetLeastGreatestFunction(const LogicalType &type) {
|
|
85548
|
+
return ScalarFunction({type}, type, LeastGreatestFunction<T, OP>, false, nullptr, nullptr, nullptr, nullptr, type);
|
|
85549
|
+
}
|
|
85550
|
+
|
|
85126
85551
|
template <class OP>
|
|
85127
85552
|
static void RegisterLeastGreatest(BuiltinFunctions &set, const string &fun_name) {
|
|
85128
85553
|
ScalarFunctionSet fun_set(fun_name);
|
|
85129
|
-
fun_set.AddFunction(ScalarFunction({LogicalType::DATE}, LogicalType::DATE, LeastGreatestFunction<date_t, OP>, false,
|
|
85130
|
-
nullptr, nullptr, nullptr, nullptr, LogicalType::DATE));
|
|
85131
|
-
fun_set.AddFunction(ScalarFunction({LogicalType::TIMESTAMP}, LogicalType::TIMESTAMP,
|
|
85132
|
-
LeastGreatestFunction<timestamp_t, OP>, false, nullptr, nullptr, nullptr,
|
|
85133
|
-
nullptr, LogicalType::TIMESTAMP));
|
|
85134
85554
|
fun_set.AddFunction(ScalarFunction({LogicalType::BIGINT}, LogicalType::BIGINT, LeastGreatestFunction<int64_t, OP>,
|
|
85135
85555
|
false, nullptr, nullptr, nullptr, nullptr, LogicalType::BIGINT));
|
|
85136
85556
|
fun_set.AddFunction(ScalarFunction({LogicalType::HUGEINT}, LogicalType::HUGEINT,
|
|
@@ -85141,6 +85561,15 @@ static void RegisterLeastGreatest(BuiltinFunctions &set, const string &fun_name)
|
|
|
85141
85561
|
fun_set.AddFunction(ScalarFunction({LogicalType::VARCHAR}, LogicalType::VARCHAR,
|
|
85142
85562
|
LeastGreatestFunction<string_t, OP, true>, false, nullptr, nullptr, nullptr,
|
|
85143
85563
|
nullptr, LogicalType::VARCHAR));
|
|
85564
|
+
|
|
85565
|
+
fun_set.AddFunction(GetLeastGreatestFunction<timestamp_t, OP>(LogicalType::TIMESTAMP));
|
|
85566
|
+
fun_set.AddFunction(GetLeastGreatestFunction<time_t, OP>(LogicalType::TIME));
|
|
85567
|
+
fun_set.AddFunction(GetLeastGreatestFunction<date_t, OP>(LogicalType::DATE));
|
|
85568
|
+
|
|
85569
|
+
fun_set.AddFunction(GetLeastGreatestFunction<timestamp_t, OP>(LogicalType::TIMESTAMP_TZ));
|
|
85570
|
+
fun_set.AddFunction(GetLeastGreatestFunction<time_t, OP>(LogicalType::TIME_TZ));
|
|
85571
|
+
fun_set.AddFunction(GetLeastGreatestFunction<date_t, OP>(LogicalType::DATE_TZ));
|
|
85572
|
+
|
|
85144
85573
|
set.AddFunction(fun_set);
|
|
85145
85574
|
}
|
|
85146
85575
|
|
|
@@ -85708,12 +86137,15 @@ static void ExecuteListExtractInternal(const idx_t count, VectorData &list, Vect
|
|
|
85708
86137
|
ListExtractTemplate<double>(count, list, offsets, child_vector, list_size, result);
|
|
85709
86138
|
break;
|
|
85710
86139
|
case LogicalTypeId::DATE:
|
|
86140
|
+
case LogicalTypeId::DATE_TZ:
|
|
85711
86141
|
ListExtractTemplate<date_t>(count, list, offsets, child_vector, list_size, result);
|
|
85712
86142
|
break;
|
|
85713
86143
|
case LogicalTypeId::TIME:
|
|
86144
|
+
case LogicalTypeId::TIME_TZ:
|
|
85714
86145
|
ListExtractTemplate<dtime_t>(count, list, offsets, child_vector, list_size, result);
|
|
85715
86146
|
break;
|
|
85716
86147
|
case LogicalTypeId::TIMESTAMP:
|
|
86148
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
85717
86149
|
ListExtractTemplate<timestamp_t>(count, list, offsets, child_vector, list_size, result);
|
|
85718
86150
|
break;
|
|
85719
86151
|
case LogicalTypeId::BLOB:
|
|
@@ -88138,8 +88570,8 @@ ScalarFunction AddFun::GetFunction(const LogicalType &left_type, const LogicalTy
|
|
|
88138
88570
|
}
|
|
88139
88571
|
break;
|
|
88140
88572
|
case LogicalTypeId::INTEGER:
|
|
88141
|
-
if (right_type.id() == LogicalTypeId::DATE) {
|
|
88142
|
-
return ScalarFunction("+", {left_type, right_type},
|
|
88573
|
+
if (right_type.id() == LogicalTypeId::DATE || right_type.id() == LogicalTypeId::DATE_TZ) {
|
|
88574
|
+
return ScalarFunction("+", {left_type, right_type}, right_type,
|
|
88143
88575
|
ScalarFunction::BinaryFunction<int32_t, date_t, date_t, AddOperator>);
|
|
88144
88576
|
}
|
|
88145
88577
|
break;
|
|
@@ -88170,6 +88602,12 @@ ScalarFunction AddFun::GetFunction(const LogicalType &left_type, const LogicalTy
|
|
|
88170
88602
|
ScalarFunction::BinaryFunction<timestamp_t, interval_t, timestamp_t, AddOperator>);
|
|
88171
88603
|
}
|
|
88172
88604
|
break;
|
|
88605
|
+
case LogicalTypeId::DATE_TZ:
|
|
88606
|
+
if (right_type.id() == LogicalTypeId::INTEGER) {
|
|
88607
|
+
return ScalarFunction("+", {left_type, right_type}, left_type,
|
|
88608
|
+
ScalarFunction::BinaryFunction<date_t, int32_t, date_t, AddOperator>);
|
|
88609
|
+
}
|
|
88610
|
+
break;
|
|
88173
88611
|
default:
|
|
88174
88612
|
break;
|
|
88175
88613
|
}
|
|
@@ -88190,6 +88628,8 @@ void AddFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
88190
88628
|
// we can add integers to dates
|
|
88191
88629
|
functions.AddFunction(GetFunction(LogicalType::DATE, LogicalType::INTEGER));
|
|
88192
88630
|
functions.AddFunction(GetFunction(LogicalType::INTEGER, LogicalType::DATE));
|
|
88631
|
+
functions.AddFunction(GetFunction(LogicalType::DATE_TZ, LogicalType::INTEGER));
|
|
88632
|
+
functions.AddFunction(GetFunction(LogicalType::INTEGER, LogicalType::DATE_TZ));
|
|
88193
88633
|
// we can add intervals together
|
|
88194
88634
|
functions.AddFunction(GetFunction(LogicalType::INTERVAL, LogicalType::INTERVAL));
|
|
88195
88635
|
// we can add intervals to dates/times/timestamps
|
|
@@ -88360,6 +88800,15 @@ ScalarFunction SubtractFun::GetFunction(const LogicalType &left_type, const Logi
|
|
|
88360
88800
|
ScalarFunction::BinaryFunction<dtime_t, interval_t, dtime_t, SubtractTimeOperator>);
|
|
88361
88801
|
}
|
|
88362
88802
|
break;
|
|
88803
|
+
case LogicalTypeId::DATE_TZ:
|
|
88804
|
+
if (right_type.id() == LogicalTypeId::DATE_TZ) {
|
|
88805
|
+
return ScalarFunction("-", {left_type, right_type}, LogicalType::BIGINT,
|
|
88806
|
+
ScalarFunction::BinaryFunction<date_t, date_t, int64_t, SubtractOperator>);
|
|
88807
|
+
} else if (right_type.id() == LogicalTypeId::INTEGER) {
|
|
88808
|
+
return ScalarFunction("-", {left_type, right_type}, left_type,
|
|
88809
|
+
ScalarFunction::BinaryFunction<date_t, int32_t, date_t, SubtractOperator>);
|
|
88810
|
+
}
|
|
88811
|
+
break;
|
|
88363
88812
|
default:
|
|
88364
88813
|
break;
|
|
88365
88814
|
}
|
|
@@ -88379,7 +88828,10 @@ void SubtractFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
88379
88828
|
}
|
|
88380
88829
|
// we can subtract dates from each other
|
|
88381
88830
|
functions.AddFunction(GetFunction(LogicalType::DATE, LogicalType::DATE));
|
|
88831
|
+
functions.AddFunction(GetFunction(LogicalType::DATE_TZ, LogicalType::DATE_TZ));
|
|
88832
|
+
// we can subtract integers from dates
|
|
88382
88833
|
functions.AddFunction(GetFunction(LogicalType::DATE, LogicalType::INTEGER));
|
|
88834
|
+
functions.AddFunction(GetFunction(LogicalType::DATE_TZ, LogicalType::INTEGER));
|
|
88383
88835
|
// we can subtract timestamps from each other
|
|
88384
88836
|
functions.AddFunction(GetFunction(LogicalType::TIMESTAMP, LogicalType::TIMESTAMP));
|
|
88385
88837
|
// we can subtract intervals from each other
|
|
@@ -99162,6 +99614,9 @@ void DuckDBTypesFunction(ClientContext &context, const FunctionData *bind_data,
|
|
|
99162
99614
|
case LogicalTypeId::TIMESTAMP:
|
|
99163
99615
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
99164
99616
|
case LogicalTypeId::INTERVAL:
|
|
99617
|
+
case LogicalTypeId::DATE_TZ:
|
|
99618
|
+
case LogicalTypeId::TIME_TZ:
|
|
99619
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
99165
99620
|
category = "DATETIME";
|
|
99166
99621
|
break;
|
|
99167
99622
|
case LogicalTypeId::CHAR:
|
|
@@ -101552,10 +102007,13 @@ duckdb_type ConvertCPPTypeToC(const LogicalType &sql_type) {
|
|
|
101552
102007
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
101553
102008
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
101554
102009
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
102010
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
101555
102011
|
return DUCKDB_TYPE_TIMESTAMP;
|
|
101556
102012
|
case LogicalTypeId::DATE:
|
|
102013
|
+
case LogicalTypeId::DATE_TZ:
|
|
101557
102014
|
return DUCKDB_TYPE_DATE;
|
|
101558
102015
|
case LogicalTypeId::TIME:
|
|
102016
|
+
case LogicalTypeId::TIME_TZ:
|
|
101559
102017
|
return DUCKDB_TYPE_TIME;
|
|
101560
102018
|
case LogicalTypeId::VARCHAR:
|
|
101561
102019
|
return DUCKDB_TYPE_VARCHAR;
|
|
@@ -101940,12 +102398,15 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
101940
102398
|
WriteData<double>(out, result->collection, col);
|
|
101941
102399
|
break;
|
|
101942
102400
|
case LogicalTypeId::DATE:
|
|
102401
|
+
case LogicalTypeId::DATE_TZ:
|
|
101943
102402
|
WriteData<date_t>(out, result->collection, col);
|
|
101944
102403
|
break;
|
|
101945
102404
|
case LogicalTypeId::TIME:
|
|
102405
|
+
case LogicalTypeId::TIME_TZ:
|
|
101946
102406
|
WriteData<dtime_t>(out, result->collection, col);
|
|
101947
102407
|
break;
|
|
101948
102408
|
case LogicalTypeId::TIMESTAMP:
|
|
102409
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
101949
102410
|
WriteData<timestamp_t>(out, result->collection, col);
|
|
101950
102411
|
break;
|
|
101951
102412
|
case LogicalTypeId::VARCHAR: {
|
|
@@ -102054,7 +102515,7 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
102054
102515
|
|
|
102055
102516
|
} // namespace duckdb
|
|
102056
102517
|
|
|
102057
|
-
static void
|
|
102518
|
+
static void DuckdbDestroyColumn(duckdb_column column, idx_t count) {
|
|
102058
102519
|
if (column.data) {
|
|
102059
102520
|
if (column.type == DUCKDB_TYPE_VARCHAR) {
|
|
102060
102521
|
// varchar, delete individual strings
|
|
@@ -102089,7 +102550,7 @@ void duckdb_destroy_result(duckdb_result *result) {
|
|
|
102089
102550
|
}
|
|
102090
102551
|
if (result->columns) {
|
|
102091
102552
|
for (idx_t i = 0; i < result->column_count; i++) {
|
|
102092
|
-
|
|
102553
|
+
DuckdbDestroyColumn(result->columns[i], result->row_count);
|
|
102093
102554
|
}
|
|
102094
102555
|
duckdb_free(result->columns);
|
|
102095
102556
|
}
|
|
@@ -113854,12 +114315,15 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
|
|
|
113854
114315
|
child.format = "u";
|
|
113855
114316
|
break;
|
|
113856
114317
|
case LogicalTypeId::DATE:
|
|
114318
|
+
case LogicalTypeId::DATE_TZ:
|
|
113857
114319
|
child.format = "tdD";
|
|
113858
114320
|
break;
|
|
113859
114321
|
case LogicalTypeId::TIME:
|
|
114322
|
+
case LogicalTypeId::TIME_TZ:
|
|
113860
114323
|
child.format = "ttu";
|
|
113861
114324
|
break;
|
|
113862
114325
|
case LogicalTypeId::TIMESTAMP:
|
|
114326
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
113863
114327
|
child.format = "tsu:";
|
|
113864
114328
|
break;
|
|
113865
114329
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
@@ -144301,7 +144765,11 @@ unique_ptr<CopyStatement> Transformer::TransformCopy(duckdb_libpgquery::PGNode *
|
|
|
144301
144765
|
// get file_path and is_from
|
|
144302
144766
|
info.file_path = stmt->filename;
|
|
144303
144767
|
info.is_from = stmt->is_from;
|
|
144304
|
-
info.
|
|
144768
|
+
if (StringUtil::EndsWith(info.file_path, ".parquet")) {
|
|
144769
|
+
info.format = "parquet";
|
|
144770
|
+
} else {
|
|
144771
|
+
info.format = "csv";
|
|
144772
|
+
}
|
|
144305
144773
|
|
|
144306
144774
|
// get select_list
|
|
144307
144775
|
if (stmt->attlist) {
|
|
@@ -153263,18 +153731,48 @@ bool BoundCastExpression::CastIsInvertible(const LogicalType &source_type, const
|
|
|
153263
153731
|
}
|
|
153264
153732
|
return true;
|
|
153265
153733
|
}
|
|
153266
|
-
if (source_type.id() == LogicalTypeId::TIMESTAMP
|
|
153267
|
-
|
|
153734
|
+
if (source_type.id() == LogicalTypeId::TIMESTAMP || source_type.id() == LogicalTypeId::TIMESTAMP_TZ) {
|
|
153735
|
+
switch (target_type.id()) {
|
|
153736
|
+
case LogicalTypeId::DATE:
|
|
153737
|
+
case LogicalTypeId::TIME:
|
|
153738
|
+
case LogicalTypeId::DATE_TZ:
|
|
153739
|
+
case LogicalTypeId::TIME_TZ:
|
|
153740
|
+
return false;
|
|
153741
|
+
default:
|
|
153742
|
+
break;
|
|
153743
|
+
}
|
|
153268
153744
|
}
|
|
153269
153745
|
if (source_type.id() == LogicalTypeId::VARCHAR) {
|
|
153270
|
-
|
|
153271
|
-
|
|
153272
|
-
|
|
153746
|
+
switch (target_type.id()) {
|
|
153747
|
+
case LogicalTypeId::DATE:
|
|
153748
|
+
case LogicalTypeId::TIME:
|
|
153749
|
+
case LogicalTypeId::TIMESTAMP:
|
|
153750
|
+
case LogicalTypeId::TIMESTAMP_NS:
|
|
153751
|
+
case LogicalTypeId::TIMESTAMP_MS:
|
|
153752
|
+
case LogicalTypeId::TIMESTAMP_SEC:
|
|
153753
|
+
case LogicalTypeId::DATE_TZ:
|
|
153754
|
+
case LogicalTypeId::TIME_TZ:
|
|
153755
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
153756
|
+
return true;
|
|
153757
|
+
default:
|
|
153758
|
+
return false;
|
|
153759
|
+
}
|
|
153273
153760
|
}
|
|
153274
153761
|
if (target_type.id() == LogicalTypeId::VARCHAR) {
|
|
153275
|
-
|
|
153276
|
-
|
|
153277
|
-
|
|
153762
|
+
switch (source_type.id()) {
|
|
153763
|
+
case LogicalTypeId::DATE:
|
|
153764
|
+
case LogicalTypeId::TIME:
|
|
153765
|
+
case LogicalTypeId::TIMESTAMP:
|
|
153766
|
+
case LogicalTypeId::TIMESTAMP_NS:
|
|
153767
|
+
case LogicalTypeId::TIMESTAMP_MS:
|
|
153768
|
+
case LogicalTypeId::TIMESTAMP_SEC:
|
|
153769
|
+
case LogicalTypeId::DATE_TZ:
|
|
153770
|
+
case LogicalTypeId::TIME_TZ:
|
|
153771
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
153772
|
+
return true;
|
|
153773
|
+
default:
|
|
153774
|
+
return false;
|
|
153775
|
+
}
|
|
153278
153776
|
}
|
|
153279
153777
|
return true;
|
|
153280
153778
|
}
|