duckdb 0.3.2-dev492.0 → 0.3.2-dev499.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 +276 -81
- package/src/duckdb.hpp +12 -5
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -39868,6 +39868,7 @@ hugeint_t ModuloOperator::Operation(hugeint_t left, hugeint_t right);
|
|
|
39868
39868
|
|
|
39869
39869
|
|
|
39870
39870
|
|
|
39871
|
+
|
|
39871
39872
|
namespace duckdb {
|
|
39872
39873
|
|
|
39873
39874
|
Value::Value(LogicalType type) : type_(move(type)), is_null(true) {
|
|
@@ -39936,66 +39937,47 @@ Value Value::MinimumValue(const LogicalType &type) {
|
|
|
39936
39937
|
case LogicalTypeId::UBIGINT:
|
|
39937
39938
|
return Value::UBIGINT(NumericLimits<uint64_t>::Minimum());
|
|
39938
39939
|
case LogicalTypeId::DATE:
|
|
39939
|
-
return Value::DATE(
|
|
39940
|
+
return Value::DATE(Date::FromDate(Date::DATE_MIN_YEAR, Date::DATE_MIN_MONTH, Date::DATE_MIN_DAY));
|
|
39940
39941
|
case LogicalTypeId::TIME:
|
|
39941
39942
|
return Value::TIME(dtime_t(0));
|
|
39942
39943
|
case LogicalTypeId::TIMESTAMP:
|
|
39943
|
-
return Value::TIMESTAMP(
|
|
39944
|
+
return Value::TIMESTAMP(Date::FromDate(Timestamp::MIN_YEAR, Timestamp::MIN_MONTH, Timestamp::MIN_DAY),
|
|
39945
|
+
dtime_t(0));
|
|
39944
39946
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
39945
|
-
return
|
|
39947
|
+
return MinimumValue(LogicalType::TIMESTAMP).CastAs(LogicalType::TIMESTAMP_S);
|
|
39946
39948
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
39947
|
-
return
|
|
39949
|
+
return MinimumValue(LogicalType::TIMESTAMP).CastAs(LogicalType::TIMESTAMP_MS);
|
|
39948
39950
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
39949
|
-
return Value::
|
|
39951
|
+
return Value::TIMESTAMPNS(timestamp_t(NumericLimits<int64_t>::Minimum()));
|
|
39950
39952
|
case LogicalTypeId::DATE_TZ:
|
|
39951
39953
|
return Value::DATETZ(date_t(NumericLimits<int32_t>::Minimum()));
|
|
39952
39954
|
case LogicalTypeId::TIME_TZ:
|
|
39953
39955
|
return Value::TIMETZ(dtime_t(0));
|
|
39954
39956
|
case LogicalTypeId::TIMESTAMP_TZ:
|
|
39955
|
-
return Value::TIMESTAMPTZ(
|
|
39957
|
+
return Value::TIMESTAMPTZ(Timestamp::FromDatetime(
|
|
39958
|
+
Date::FromDate(Timestamp::MIN_YEAR, Timestamp::MIN_MONTH, Timestamp::MIN_DAY), dtime_t(0)));
|
|
39956
39959
|
case LogicalTypeId::FLOAT:
|
|
39957
39960
|
return Value::FLOAT(NumericLimits<float>::Minimum());
|
|
39958
39961
|
case LogicalTypeId::DOUBLE:
|
|
39959
39962
|
return Value::DOUBLE(NumericLimits<double>::Minimum());
|
|
39960
39963
|
case LogicalTypeId::DECIMAL: {
|
|
39961
|
-
|
|
39964
|
+
auto width = DecimalType::GetWidth(type);
|
|
39965
|
+
auto scale = DecimalType::GetScale(type);
|
|
39962
39966
|
switch (type.InternalType()) {
|
|
39963
39967
|
case PhysicalType::INT16:
|
|
39964
|
-
|
|
39965
|
-
break;
|
|
39968
|
+
return Value::DECIMAL(int16_t(-NumericHelper::POWERS_OF_TEN[width] + 1), width, scale);
|
|
39966
39969
|
case PhysicalType::INT32:
|
|
39967
|
-
|
|
39968
|
-
break;
|
|
39970
|
+
return Value::DECIMAL(int32_t(-NumericHelper::POWERS_OF_TEN[width] + 1), width, scale);
|
|
39969
39971
|
case PhysicalType::INT64:
|
|
39970
|
-
|
|
39971
|
-
break;
|
|
39972
|
+
return Value::DECIMAL(int64_t(-NumericHelper::POWERS_OF_TEN[width] + 1), width, scale);
|
|
39972
39973
|
case PhysicalType::INT128:
|
|
39973
|
-
|
|
39974
|
-
break;
|
|
39974
|
+
return Value::DECIMAL(-Hugeint::POWERS_OF_TEN[width] + 1, width, scale);
|
|
39975
39975
|
default:
|
|
39976
39976
|
throw InternalException("Unknown decimal type");
|
|
39977
39977
|
}
|
|
39978
|
-
result.type_ = type;
|
|
39979
|
-
return result;
|
|
39980
|
-
}
|
|
39981
|
-
case LogicalTypeId::ENUM: {
|
|
39982
|
-
Value result;
|
|
39983
|
-
switch (type.InternalType()) {
|
|
39984
|
-
case PhysicalType::UINT8:
|
|
39985
|
-
result = Value::MinimumValue(LogicalType::UTINYINT);
|
|
39986
|
-
break;
|
|
39987
|
-
case PhysicalType::UINT16:
|
|
39988
|
-
result = Value::MinimumValue(LogicalType::USMALLINT);
|
|
39989
|
-
break;
|
|
39990
|
-
case PhysicalType::UINT32:
|
|
39991
|
-
result = Value::MinimumValue(LogicalType::UINTEGER);
|
|
39992
|
-
break;
|
|
39993
|
-
default:
|
|
39994
|
-
throw InternalException("ENUM can only have unsigned integers (except UINT64) as physical types");
|
|
39995
|
-
}
|
|
39996
|
-
result.type_ = type;
|
|
39997
|
-
return result;
|
|
39998
39978
|
}
|
|
39979
|
+
case LogicalTypeId::ENUM:
|
|
39980
|
+
return Value::ENUM(0, type);
|
|
39999
39981
|
default:
|
|
40000
39982
|
throw InvalidTypeException(type, "MinimumValue requires numeric type");
|
|
40001
39983
|
}
|
|
@@ -40004,7 +39986,7 @@ Value Value::MinimumValue(const LogicalType &type) {
|
|
|
40004
39986
|
Value Value::MaximumValue(const LogicalType &type) {
|
|
40005
39987
|
switch (type.id()) {
|
|
40006
39988
|
case LogicalTypeId::BOOLEAN:
|
|
40007
|
-
return Value::BOOLEAN(
|
|
39989
|
+
return Value::BOOLEAN(true);
|
|
40008
39990
|
case LogicalTypeId::TINYINT:
|
|
40009
39991
|
return Value::TINYINT(NumericLimits<int8_t>::Maximum());
|
|
40010
39992
|
case LogicalTypeId::SMALLINT:
|
|
@@ -40027,21 +40009,21 @@ Value Value::MaximumValue(const LogicalType &type) {
|
|
|
40027
40009
|
case LogicalTypeId::UBIGINT:
|
|
40028
40010
|
return Value::UBIGINT(NumericLimits<uint64_t>::Maximum());
|
|
40029
40011
|
case LogicalTypeId::DATE:
|
|
40030
|
-
return Value::DATE(
|
|
40012
|
+
return Value::DATE(Date::FromDate(Date::DATE_MAX_YEAR, Date::DATE_MAX_MONTH, Date::DATE_MAX_DAY));
|
|
40031
40013
|
case LogicalTypeId::TIME:
|
|
40032
|
-
return Value::TIME(dtime_t(Interval::SECS_PER_DAY * Interval::MICROS_PER_SEC));
|
|
40014
|
+
return Value::TIME(dtime_t(Interval::SECS_PER_DAY * Interval::MICROS_PER_SEC - 1));
|
|
40033
40015
|
case LogicalTypeId::TIMESTAMP:
|
|
40034
40016
|
return Value::TIMESTAMP(timestamp_t(NumericLimits<int64_t>::Maximum()));
|
|
40035
40017
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
40036
|
-
return
|
|
40018
|
+
return MaximumValue(LogicalType::TIMESTAMP).CastAs(LogicalType::TIMESTAMP_MS);
|
|
40037
40019
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
40038
|
-
return Value::
|
|
40020
|
+
return Value::TIMESTAMPNS(timestamp_t(NumericLimits<int64_t>::Maximum()));
|
|
40039
40021
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
40040
|
-
return
|
|
40022
|
+
return MaximumValue(LogicalType::TIMESTAMP).CastAs(LogicalType::TIMESTAMP_S);
|
|
40041
40023
|
case LogicalTypeId::DATE_TZ:
|
|
40042
40024
|
return Value::DATETZ(date_t(NumericLimits<int32_t>::Maximum()));
|
|
40043
40025
|
case LogicalTypeId::TIME_TZ:
|
|
40044
|
-
return Value::TIMETZ(dtime_t(Interval::SECS_PER_DAY * Interval::MICROS_PER_SEC));
|
|
40026
|
+
return Value::TIMETZ(dtime_t(Interval::SECS_PER_DAY * Interval::MICROS_PER_SEC - 1));
|
|
40045
40027
|
case LogicalTypeId::TIMESTAMP_TZ:
|
|
40046
40028
|
return Value::TIMESTAMPTZ(timestamp_t(NumericLimits<int64_t>::Maximum()));
|
|
40047
40029
|
case LogicalTypeId::FLOAT:
|
|
@@ -40049,44 +40031,23 @@ Value Value::MaximumValue(const LogicalType &type) {
|
|
|
40049
40031
|
case LogicalTypeId::DOUBLE:
|
|
40050
40032
|
return Value::DOUBLE(NumericLimits<double>::Maximum());
|
|
40051
40033
|
case LogicalTypeId::DECIMAL: {
|
|
40052
|
-
|
|
40034
|
+
auto width = DecimalType::GetWidth(type);
|
|
40035
|
+
auto scale = DecimalType::GetScale(type);
|
|
40053
40036
|
switch (type.InternalType()) {
|
|
40054
40037
|
case PhysicalType::INT16:
|
|
40055
|
-
|
|
40056
|
-
break;
|
|
40038
|
+
return Value::DECIMAL(int16_t(NumericHelper::POWERS_OF_TEN[width] - 1), width, scale);
|
|
40057
40039
|
case PhysicalType::INT32:
|
|
40058
|
-
|
|
40059
|
-
break;
|
|
40040
|
+
return Value::DECIMAL(int32_t(NumericHelper::POWERS_OF_TEN[width] - 1), width, scale);
|
|
40060
40041
|
case PhysicalType::INT64:
|
|
40061
|
-
|
|
40062
|
-
break;
|
|
40042
|
+
return Value::DECIMAL(int64_t(NumericHelper::POWERS_OF_TEN[width] - 1), width, scale);
|
|
40063
40043
|
case PhysicalType::INT128:
|
|
40064
|
-
|
|
40065
|
-
break;
|
|
40044
|
+
return Value::DECIMAL(Hugeint::POWERS_OF_TEN[width] - 1, width, scale);
|
|
40066
40045
|
default:
|
|
40067
40046
|
throw InternalException("Unknown decimal type");
|
|
40068
40047
|
}
|
|
40069
|
-
result.type_ = type;
|
|
40070
|
-
return result;
|
|
40071
|
-
}
|
|
40072
|
-
case LogicalTypeId::ENUM: {
|
|
40073
|
-
Value result;
|
|
40074
|
-
switch (type.InternalType()) {
|
|
40075
|
-
case PhysicalType::UINT8:
|
|
40076
|
-
result = Value::MaximumValue(LogicalType::UTINYINT);
|
|
40077
|
-
break;
|
|
40078
|
-
case PhysicalType::UINT16:
|
|
40079
|
-
result = Value::MaximumValue(LogicalType::USMALLINT);
|
|
40080
|
-
break;
|
|
40081
|
-
case PhysicalType::UINT32:
|
|
40082
|
-
result = Value::MaximumValue(LogicalType::UINTEGER);
|
|
40083
|
-
break;
|
|
40084
|
-
default:
|
|
40085
|
-
throw InternalException("ENUM can only have unsigned integers (except UINT64) as physical types");
|
|
40086
|
-
}
|
|
40087
|
-
result.type_ = type;
|
|
40088
|
-
return result;
|
|
40089
40048
|
}
|
|
40049
|
+
case LogicalTypeId::ENUM:
|
|
40050
|
+
return Value::ENUM(EnumType::GetSize(type) - 1, type);
|
|
40090
40051
|
default:
|
|
40091
40052
|
throw InvalidTypeException(type, "MaximumValue requires numeric type");
|
|
40092
40053
|
}
|
|
@@ -40319,21 +40280,21 @@ Value Value::TIMESTAMPTZ(timestamp_t value) {
|
|
|
40319
40280
|
return result;
|
|
40320
40281
|
}
|
|
40321
40282
|
|
|
40322
|
-
Value Value::
|
|
40283
|
+
Value Value::TIMESTAMPNS(timestamp_t timestamp) {
|
|
40323
40284
|
Value result(LogicalType::TIMESTAMP_NS);
|
|
40324
40285
|
result.value_.timestamp = timestamp;
|
|
40325
40286
|
result.is_null = false;
|
|
40326
40287
|
return result;
|
|
40327
40288
|
}
|
|
40328
40289
|
|
|
40329
|
-
Value Value::
|
|
40290
|
+
Value Value::TIMESTAMPMS(timestamp_t timestamp) {
|
|
40330
40291
|
Value result(LogicalType::TIMESTAMP_MS);
|
|
40331
40292
|
result.value_.timestamp = timestamp;
|
|
40332
40293
|
result.is_null = false;
|
|
40333
40294
|
return result;
|
|
40334
40295
|
}
|
|
40335
40296
|
|
|
40336
|
-
Value Value::
|
|
40297
|
+
Value Value::TIMESTAMPSEC(timestamp_t timestamp) {
|
|
40337
40298
|
Value result(LogicalType::TIMESTAMP_S);
|
|
40338
40299
|
result.value_.timestamp = timestamp;
|
|
40339
40300
|
result.is_null = false;
|
|
@@ -40747,11 +40708,17 @@ Value Value::Numeric(const LogicalType &type, int64_t value) {
|
|
|
40747
40708
|
case LogicalTypeId::TIMESTAMP:
|
|
40748
40709
|
return Value::TIMESTAMP(timestamp_t(value));
|
|
40749
40710
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
40750
|
-
return Value::
|
|
40711
|
+
return Value::TIMESTAMPNS(timestamp_t(value));
|
|
40751
40712
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
40752
|
-
return Value::
|
|
40713
|
+
return Value::TIMESTAMPMS(timestamp_t(value));
|
|
40753
40714
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
40754
|
-
return Value::
|
|
40715
|
+
return Value::TIMESTAMPSEC(timestamp_t(value));
|
|
40716
|
+
case LogicalTypeId::DATE_TZ:
|
|
40717
|
+
return Value::DATETZ(date_t(value));
|
|
40718
|
+
case LogicalTypeId::TIME_TZ:
|
|
40719
|
+
return Value::TIMETZ(dtime_t(value));
|
|
40720
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
40721
|
+
return Value::TIMESTAMPTZ(timestamp_t(value));
|
|
40755
40722
|
case LogicalTypeId::ENUM:
|
|
40756
40723
|
switch (type.InternalType()) {
|
|
40757
40724
|
case PhysicalType::UINT8:
|
|
@@ -41781,11 +41748,11 @@ Value Vector::GetValue(idx_t index) const {
|
|
|
41781
41748
|
case LogicalTypeId::TIMESTAMP:
|
|
41782
41749
|
return Value::TIMESTAMP(((timestamp_t *)data)[index]);
|
|
41783
41750
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
41784
|
-
return Value::
|
|
41751
|
+
return Value::TIMESTAMPNS(((timestamp_t *)data)[index]);
|
|
41785
41752
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
41786
|
-
return Value::
|
|
41753
|
+
return Value::TIMESTAMPMS(((timestamp_t *)data)[index]);
|
|
41787
41754
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
41788
|
-
return Value::
|
|
41755
|
+
return Value::TIMESTAMPSEC(((timestamp_t *)data)[index]);
|
|
41789
41756
|
case LogicalTypeId::TIMESTAMP_TZ:
|
|
41790
41757
|
return Value::TIMESTAMPTZ(((timestamp_t *)data)[index]);
|
|
41791
41758
|
case LogicalTypeId::HUGEINT:
|
|
@@ -41966,7 +41933,7 @@ void Vector::Normalify(idx_t count) {
|
|
|
41966
41933
|
// allocate a new buffer for the vector
|
|
41967
41934
|
auto old_buffer = move(buffer);
|
|
41968
41935
|
auto old_data = data;
|
|
41969
|
-
buffer = VectorBuffer::CreateStandardVector(type);
|
|
41936
|
+
buffer = VectorBuffer::CreateStandardVector(type, MaxValue<idx_t>(STANDARD_VECTOR_SIZE, count));
|
|
41970
41937
|
data = buffer->GetData();
|
|
41971
41938
|
vector_type = VectorType::FLAT_VECTOR;
|
|
41972
41939
|
if (is_null) {
|
|
@@ -44513,6 +44480,13 @@ LogicalType LogicalType::MAP(child_list_t<LogicalType> children) {
|
|
|
44513
44480
|
return LogicalType(LogicalTypeId::MAP, move(info));
|
|
44514
44481
|
}
|
|
44515
44482
|
|
|
44483
|
+
LogicalType LogicalType::MAP(LogicalType key, LogicalType value) {
|
|
44484
|
+
child_list_t<LogicalType> child_types;
|
|
44485
|
+
child_types.push_back({"key", LogicalType::LIST(move(key))});
|
|
44486
|
+
child_types.push_back({"value", LogicalType::LIST(move(value))});
|
|
44487
|
+
return LogicalType::MAP(move(child_types));
|
|
44488
|
+
}
|
|
44489
|
+
|
|
44516
44490
|
//===--------------------------------------------------------------------===//
|
|
44517
44491
|
// User Type
|
|
44518
44492
|
//===--------------------------------------------------------------------===//
|
|
@@ -97252,6 +97226,10 @@ struct DuckDBViewsFun {
|
|
|
97252
97226
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
97253
97227
|
};
|
|
97254
97228
|
|
|
97229
|
+
struct TestAllTypesFun {
|
|
97230
|
+
static void RegisterFunction(BuiltinFunctions &set);
|
|
97231
|
+
};
|
|
97232
|
+
|
|
97255
97233
|
} // namespace duckdb
|
|
97256
97234
|
|
|
97257
97235
|
|
|
@@ -100864,6 +100842,222 @@ void PragmaTableInfo::RegisterFunction(BuiltinFunctions &set) {
|
|
|
100864
100842
|
} // namespace duckdb
|
|
100865
100843
|
|
|
100866
100844
|
|
|
100845
|
+
|
|
100846
|
+
namespace duckdb {
|
|
100847
|
+
|
|
100848
|
+
struct TestAllTypesData : public FunctionOperatorData {
|
|
100849
|
+
TestAllTypesData() : offset(0) {
|
|
100850
|
+
}
|
|
100851
|
+
|
|
100852
|
+
vector<vector<Value>> entries;
|
|
100853
|
+
idx_t offset;
|
|
100854
|
+
};
|
|
100855
|
+
|
|
100856
|
+
struct TestType {
|
|
100857
|
+
TestType(LogicalType type_p, string name_p)
|
|
100858
|
+
: type(move(type_p)), name(move(name_p)), min_value(Value::MinimumValue(type)),
|
|
100859
|
+
max_value(Value::MaximumValue(type)) {
|
|
100860
|
+
}
|
|
100861
|
+
TestType(LogicalType type_p, string name_p, Value min, Value max)
|
|
100862
|
+
: type(move(type_p)), name(move(name_p)), min_value(move(min)), max_value(move(max)) {
|
|
100863
|
+
}
|
|
100864
|
+
|
|
100865
|
+
LogicalType type;
|
|
100866
|
+
string name;
|
|
100867
|
+
Value min_value;
|
|
100868
|
+
Value max_value;
|
|
100869
|
+
};
|
|
100870
|
+
|
|
100871
|
+
static vector<TestType> GetTestTypes() {
|
|
100872
|
+
vector<TestType> result;
|
|
100873
|
+
// scalar types/numerics
|
|
100874
|
+
result.emplace_back(LogicalType::BOOLEAN, "bool");
|
|
100875
|
+
result.emplace_back(LogicalType::TINYINT, "tinyint");
|
|
100876
|
+
result.emplace_back(LogicalType::SMALLINT, "smallint");
|
|
100877
|
+
result.emplace_back(LogicalType::INTEGER, "int");
|
|
100878
|
+
result.emplace_back(LogicalType::BIGINT, "bigint");
|
|
100879
|
+
result.emplace_back(LogicalType::HUGEINT, "hugeint");
|
|
100880
|
+
result.emplace_back(LogicalType::UTINYINT, "utinyint");
|
|
100881
|
+
result.emplace_back(LogicalType::USMALLINT, "usmallint");
|
|
100882
|
+
result.emplace_back(LogicalType::UINTEGER, "uint");
|
|
100883
|
+
result.emplace_back(LogicalType::UBIGINT, "ubigint");
|
|
100884
|
+
result.emplace_back(LogicalType::DATE, "date");
|
|
100885
|
+
result.emplace_back(LogicalType::TIME, "time");
|
|
100886
|
+
result.emplace_back(LogicalType::TIMESTAMP, "timestamp");
|
|
100887
|
+
result.emplace_back(LogicalType::TIMESTAMP_S, "timestamp_s");
|
|
100888
|
+
result.emplace_back(LogicalType::TIMESTAMP_MS, "timestamp_ms");
|
|
100889
|
+
result.emplace_back(LogicalType::TIMESTAMP_NS, "timestamp_ns");
|
|
100890
|
+
result.emplace_back(LogicalType::DATE_TZ, "date_tz");
|
|
100891
|
+
result.emplace_back(LogicalType::TIME_TZ, "time_tz");
|
|
100892
|
+
result.emplace_back(LogicalType::TIMESTAMP_TZ, "timestamp_tz");
|
|
100893
|
+
result.emplace_back(LogicalType::FLOAT, "float");
|
|
100894
|
+
result.emplace_back(LogicalType::DOUBLE, "double");
|
|
100895
|
+
result.emplace_back(LogicalType::DECIMAL(4, 1), "dec_4_1");
|
|
100896
|
+
result.emplace_back(LogicalType::DECIMAL(9, 4), "dec_9_4");
|
|
100897
|
+
result.emplace_back(LogicalType::DECIMAL(18, 6), "dec_18_3");
|
|
100898
|
+
result.emplace_back(LogicalType::DECIMAL(38, 10), "dec38_10");
|
|
100899
|
+
result.emplace_back(LogicalType::UUID, "uuid");
|
|
100900
|
+
// interval
|
|
100901
|
+
interval_t min_interval;
|
|
100902
|
+
min_interval.months = 0;
|
|
100903
|
+
min_interval.days = 0;
|
|
100904
|
+
min_interval.micros = 0;
|
|
100905
|
+
|
|
100906
|
+
interval_t max_interval;
|
|
100907
|
+
max_interval.months = 999;
|
|
100908
|
+
max_interval.days = 999;
|
|
100909
|
+
max_interval.micros = 999999999;
|
|
100910
|
+
result.emplace_back(LogicalType::INTERVAL, "interval", Value::INTERVAL(min_interval),
|
|
100911
|
+
Value::INTERVAL(max_interval));
|
|
100912
|
+
// strings/blobs
|
|
100913
|
+
result.emplace_back(LogicalType::VARCHAR, "varchar", Value("🦆🦆🦆🦆🦆🦆"), Value("goose"));
|
|
100914
|
+
result.emplace_back(LogicalType::BLOB, "blob", Value::BLOB("thisisalongblob\\x00withnullbytes"),
|
|
100915
|
+
Value("\\x00\\x00\\x00a"));
|
|
100916
|
+
|
|
100917
|
+
// enums
|
|
100918
|
+
vector<string> small_enum {"DUCK_DUCK_ENUM", "GOOSE"};
|
|
100919
|
+
result.emplace_back(LogicalType::ENUM("small_enum", small_enum), "small_enum");
|
|
100920
|
+
|
|
100921
|
+
vector<string> medium_enum;
|
|
100922
|
+
for (idx_t i = 0; i < 300; i++) {
|
|
100923
|
+
medium_enum.push_back(string("enum_") + to_string(i));
|
|
100924
|
+
}
|
|
100925
|
+
result.emplace_back(LogicalType::ENUM("medium_enum", medium_enum), "medium_enum");
|
|
100926
|
+
|
|
100927
|
+
// this is a big one... not sure if we should push this one here, but it's required for completeness
|
|
100928
|
+
vector<string> large_enum;
|
|
100929
|
+
for (idx_t i = 0; i < 70000; i++) {
|
|
100930
|
+
large_enum.push_back(string("enum_") + to_string(i));
|
|
100931
|
+
}
|
|
100932
|
+
result.emplace_back(LogicalType::ENUM("large_enum", large_enum), "large_enum");
|
|
100933
|
+
|
|
100934
|
+
// arrays
|
|
100935
|
+
auto int_list_type = LogicalType::LIST(LogicalType::INTEGER);
|
|
100936
|
+
auto empty_int_list = Value::EMPTYLIST(LogicalType::INTEGER);
|
|
100937
|
+
auto int_list = Value::LIST({Value::INTEGER(42), Value::INTEGER(999), Value(LogicalType::INTEGER),
|
|
100938
|
+
Value(LogicalType::INTEGER), Value::INTEGER(-42)});
|
|
100939
|
+
result.emplace_back(int_list_type, "int_array", empty_int_list, int_list);
|
|
100940
|
+
|
|
100941
|
+
auto varchar_list_type = LogicalType::LIST(LogicalType::VARCHAR);
|
|
100942
|
+
auto empty_varchar_list = Value::EMPTYLIST(LogicalType::VARCHAR);
|
|
100943
|
+
auto varchar_list =
|
|
100944
|
+
Value::LIST({Value("🦆🦆🦆🦆🦆🦆"), Value("goose"), Value(LogicalType::VARCHAR), Value("")});
|
|
100945
|
+
result.emplace_back(varchar_list_type, "varchar_array", empty_varchar_list, varchar_list);
|
|
100946
|
+
|
|
100947
|
+
// nested arrays
|
|
100948
|
+
auto nested_list_type = LogicalType::LIST(int_list_type);
|
|
100949
|
+
auto empty_nested_list = Value::EMPTYLIST(int_list_type);
|
|
100950
|
+
auto nested_int_list = Value::LIST({empty_int_list, int_list, Value(int_list_type), empty_int_list, int_list});
|
|
100951
|
+
result.emplace_back(nested_list_type, "nested_int_array", empty_nested_list, nested_int_list);
|
|
100952
|
+
|
|
100953
|
+
// structs
|
|
100954
|
+
child_list_t<LogicalType> struct_type_list;
|
|
100955
|
+
struct_type_list.push_back(make_pair("a", LogicalType::INTEGER));
|
|
100956
|
+
struct_type_list.push_back(make_pair("b", LogicalType::VARCHAR));
|
|
100957
|
+
auto struct_type = LogicalType::STRUCT(move(struct_type_list));
|
|
100958
|
+
|
|
100959
|
+
child_list_t<Value> min_struct_list;
|
|
100960
|
+
min_struct_list.push_back(make_pair("a", Value(LogicalType::INTEGER)));
|
|
100961
|
+
min_struct_list.push_back(make_pair("b", Value(LogicalType::VARCHAR)));
|
|
100962
|
+
auto min_struct_val = Value::STRUCT(move(min_struct_list));
|
|
100963
|
+
|
|
100964
|
+
child_list_t<Value> max_struct_list;
|
|
100965
|
+
max_struct_list.push_back(make_pair("a", Value::INTEGER(42)));
|
|
100966
|
+
max_struct_list.push_back(make_pair("b", Value("🦆🦆🦆🦆🦆🦆")));
|
|
100967
|
+
auto max_struct_val = Value::STRUCT(move(max_struct_list));
|
|
100968
|
+
|
|
100969
|
+
result.emplace_back(struct_type, "struct", min_struct_val, max_struct_val);
|
|
100970
|
+
|
|
100971
|
+
// structs with lists
|
|
100972
|
+
child_list_t<LogicalType> struct_list_type_list;
|
|
100973
|
+
struct_list_type_list.push_back(make_pair("a", int_list_type));
|
|
100974
|
+
struct_list_type_list.push_back(make_pair("b", varchar_list_type));
|
|
100975
|
+
auto struct_list_type = LogicalType::STRUCT(move(struct_list_type_list));
|
|
100976
|
+
|
|
100977
|
+
child_list_t<Value> min_struct_vl_list;
|
|
100978
|
+
min_struct_vl_list.push_back(make_pair("a", Value(int_list_type)));
|
|
100979
|
+
min_struct_vl_list.push_back(make_pair("b", Value(varchar_list_type)));
|
|
100980
|
+
auto min_struct_val_list = Value::STRUCT(move(min_struct_vl_list));
|
|
100981
|
+
|
|
100982
|
+
child_list_t<Value> max_struct_vl_list;
|
|
100983
|
+
max_struct_vl_list.push_back(make_pair("a", int_list));
|
|
100984
|
+
max_struct_vl_list.push_back(make_pair("b", varchar_list));
|
|
100985
|
+
auto max_struct_val_list = Value::STRUCT(move(max_struct_vl_list));
|
|
100986
|
+
|
|
100987
|
+
result.emplace_back(struct_list_type, "struct_of_arrays", move(min_struct_val_list), move(max_struct_val_list));
|
|
100988
|
+
|
|
100989
|
+
// array of structs
|
|
100990
|
+
auto array_of_structs_type = LogicalType::LIST(struct_type);
|
|
100991
|
+
auto min_array_of_struct_val = Value::EMPTYLIST(struct_type);
|
|
100992
|
+
auto max_array_of_struct_val = Value::LIST({min_struct_val, max_struct_val, Value(struct_type)});
|
|
100993
|
+
result.emplace_back(array_of_structs_type, "array_of_structs", move(min_array_of_struct_val),
|
|
100994
|
+
move(max_array_of_struct_val));
|
|
100995
|
+
|
|
100996
|
+
// map
|
|
100997
|
+
auto map_type = LogicalType::MAP(LogicalType::VARCHAR, LogicalType::VARCHAR);
|
|
100998
|
+
auto min_map_value = Value::MAP(Value::EMPTYLIST(LogicalType::VARCHAR), Value::EMPTYLIST(LogicalType::VARCHAR));
|
|
100999
|
+
auto max_map_value = Value::MAP(Value::LIST({Value("key1"), Value("key2")}),
|
|
101000
|
+
Value::LIST({Value("🦆🦆🦆🦆🦆🦆"), Value("goose")}));
|
|
101001
|
+
result.emplace_back(map_type, "map", move(min_map_value), move(max_map_value));
|
|
101002
|
+
|
|
101003
|
+
return result;
|
|
101004
|
+
}
|
|
101005
|
+
|
|
101006
|
+
static unique_ptr<FunctionData> TestAllTypesBind(ClientContext &context, vector<Value> &inputs,
|
|
101007
|
+
unordered_map<string, Value> &named_parameters,
|
|
101008
|
+
vector<LogicalType> &input_table_types,
|
|
101009
|
+
vector<string> &input_table_names, vector<LogicalType> &return_types,
|
|
101010
|
+
vector<string> &names) {
|
|
101011
|
+
auto test_types = GetTestTypes();
|
|
101012
|
+
for (auto &test_type : test_types) {
|
|
101013
|
+
return_types.push_back(move(test_type.type));
|
|
101014
|
+
names.push_back(move(test_type.name));
|
|
101015
|
+
}
|
|
101016
|
+
return nullptr;
|
|
101017
|
+
}
|
|
101018
|
+
|
|
101019
|
+
unique_ptr<FunctionOperatorData> TestAllTypesInit(ClientContext &context, const FunctionData *bind_data,
|
|
101020
|
+
const vector<column_t> &column_ids, TableFilterCollection *filters) {
|
|
101021
|
+
auto result = make_unique<TestAllTypesData>();
|
|
101022
|
+
auto test_types = GetTestTypes();
|
|
101023
|
+
// 3 rows: min, max and NULL
|
|
101024
|
+
result->entries.resize(3);
|
|
101025
|
+
// initialize the values
|
|
101026
|
+
for (auto &test_type : test_types) {
|
|
101027
|
+
result->entries[0].push_back(move(test_type.min_value));
|
|
101028
|
+
result->entries[1].push_back(move(test_type.max_value));
|
|
101029
|
+
result->entries[2].emplace_back(move(test_type.type));
|
|
101030
|
+
}
|
|
101031
|
+
return move(result);
|
|
101032
|
+
}
|
|
101033
|
+
|
|
101034
|
+
void TestAllTypesFunction(ClientContext &context, const FunctionData *bind_data, FunctionOperatorData *operator_state,
|
|
101035
|
+
DataChunk *input, DataChunk &output) {
|
|
101036
|
+
auto &data = (TestAllTypesData &)*operator_state;
|
|
101037
|
+
if (data.offset >= data.entries.size()) {
|
|
101038
|
+
// finished returning values
|
|
101039
|
+
return;
|
|
101040
|
+
}
|
|
101041
|
+
// start returning values
|
|
101042
|
+
// either fill up the chunk or return all the remaining columns
|
|
101043
|
+
idx_t count = 0;
|
|
101044
|
+
while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
|
|
101045
|
+
auto &vals = data.entries[data.offset++];
|
|
101046
|
+
for (idx_t col_idx = 0; col_idx < vals.size(); col_idx++) {
|
|
101047
|
+
output.SetValue(col_idx, count, vals[col_idx]);
|
|
101048
|
+
}
|
|
101049
|
+
count++;
|
|
101050
|
+
}
|
|
101051
|
+
output.SetCardinality(count);
|
|
101052
|
+
}
|
|
101053
|
+
|
|
101054
|
+
void TestAllTypesFun::RegisterFunction(BuiltinFunctions &set) {
|
|
101055
|
+
set.AddFunction(TableFunction("test_all_types", {}, TestAllTypesFunction, TestAllTypesBind, TestAllTypesInit));
|
|
101056
|
+
}
|
|
101057
|
+
|
|
101058
|
+
} // namespace duckdb
|
|
101059
|
+
|
|
101060
|
+
|
|
100867
101061
|
//===----------------------------------------------------------------------===//
|
|
100868
101062
|
// DuckDB
|
|
100869
101063
|
//
|
|
@@ -100992,6 +101186,7 @@ void BuiltinFunctions::RegisterSQLiteFunctions() {
|
|
|
100992
101186
|
DuckDBTablesFun::RegisterFunction(*this);
|
|
100993
101187
|
DuckDBTypesFun::RegisterFunction(*this);
|
|
100994
101188
|
DuckDBViewsFun::RegisterFunction(*this);
|
|
101189
|
+
TestAllTypesFun::RegisterFunction(*this);
|
|
100995
101190
|
}
|
|
100996
101191
|
|
|
100997
101192
|
} // namespace duckdb
|
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.3.2-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "915530a92"
|
|
14
|
+
#define DUCKDB_VERSION "0.3.2-dev499"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|
|
@@ -1039,6 +1039,7 @@ public:
|
|
|
1039
1039
|
DUCKDB_API static LogicalType LIST( LogicalType child); // NOLINT
|
|
1040
1040
|
DUCKDB_API static LogicalType STRUCT( child_list_t<LogicalType> children); // NOLINT
|
|
1041
1041
|
DUCKDB_API static LogicalType MAP( child_list_t<LogicalType> children); // NOLINT
|
|
1042
|
+
DUCKDB_API static LogicalType MAP(LogicalType key, LogicalType value); // NOLINT
|
|
1042
1043
|
DUCKDB_API static LogicalType ENUM(const string &enum_name, const vector<string> &ordered_data); // NOLINT
|
|
1043
1044
|
DUCKDB_API static LogicalType USER(const string &user_type_name); // NOLINT
|
|
1044
1045
|
//! A list of all NUMERIC types (integral and floating point types)
|
|
@@ -2599,9 +2600,9 @@ public:
|
|
|
2599
2600
|
DUCKDB_API static Value TIMESTAMP(date_t date, dtime_t time);
|
|
2600
2601
|
//! Create a timestamp Value from a specified timestamp
|
|
2601
2602
|
DUCKDB_API static Value TIMESTAMP(timestamp_t timestamp);
|
|
2602
|
-
DUCKDB_API static Value
|
|
2603
|
-
DUCKDB_API static Value
|
|
2604
|
-
DUCKDB_API static Value
|
|
2603
|
+
DUCKDB_API static Value TIMESTAMPNS(timestamp_t timestamp);
|
|
2604
|
+
DUCKDB_API static Value TIMESTAMPMS(timestamp_t timestamp);
|
|
2605
|
+
DUCKDB_API static Value TIMESTAMPSEC(timestamp_t timestamp);
|
|
2605
2606
|
DUCKDB_API static Value TIMESTAMPTZ(timestamp_t timestamp);
|
|
2606
2607
|
//! Create a timestamp Value from a specified timestamp in separate values
|
|
2607
2608
|
DUCKDB_API static Value TIMESTAMP(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, int32_t sec,
|
|
@@ -11819,6 +11820,12 @@ struct timestamp_struct {
|
|
|
11819
11820
|
//! The Timestamp class is a static class that holds helper functions for the Timestamp
|
|
11820
11821
|
//! type.
|
|
11821
11822
|
class Timestamp {
|
|
11823
|
+
public:
|
|
11824
|
+
// min timestamp is 290308-12-22 (BC)
|
|
11825
|
+
constexpr static const int32_t MIN_YEAR = -290308;
|
|
11826
|
+
constexpr static const int32_t MIN_MONTH = 12;
|
|
11827
|
+
constexpr static const int32_t MIN_DAY = 22;
|
|
11828
|
+
|
|
11822
11829
|
public:
|
|
11823
11830
|
//! Convert a string in the format "YYYY-MM-DD hh:mm:ss" to a timestamp object
|
|
11824
11831
|
DUCKDB_API static timestamp_t FromString(const string &str);
|