duckdb 0.3.3-dev1297.0 → 0.3.3-dev1306.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 +222 -258
- package/src/duckdb.hpp +12 -28
- package/src/parquet-amalgamation.cpp +36297 -36297
package/src/duckdb.cpp
CHANGED
|
@@ -26276,45 +26276,45 @@ using ValidityBytes = RowLayout::ValidityBytes;
|
|
|
26276
26276
|
using Predicates = RowOperations::Predicates;
|
|
26277
26277
|
|
|
26278
26278
|
template <typename OP>
|
|
26279
|
-
static idx_t SelectComparison(Vector &left, Vector &right,
|
|
26279
|
+
static idx_t SelectComparison(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
26280
26280
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
26281
26281
|
throw NotImplementedException("Unsupported nested comparison operand for RowOperations::Match");
|
|
26282
26282
|
}
|
|
26283
26283
|
|
|
26284
26284
|
template <>
|
|
26285
|
-
idx_t SelectComparison<Equals>(Vector &left, Vector &right,
|
|
26285
|
+
idx_t SelectComparison<Equals>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
26286
26286
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
26287
|
-
return VectorOperations::NestedEquals(left, right,
|
|
26287
|
+
return VectorOperations::NestedEquals(left, right, sel, count, true_sel, false_sel);
|
|
26288
26288
|
}
|
|
26289
26289
|
|
|
26290
26290
|
template <>
|
|
26291
|
-
idx_t SelectComparison<NotEquals>(Vector &left, Vector &right,
|
|
26291
|
+
idx_t SelectComparison<NotEquals>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
26292
26292
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
26293
|
-
return VectorOperations::NestedNotEquals(left, right,
|
|
26293
|
+
return VectorOperations::NestedNotEquals(left, right, sel, count, true_sel, false_sel);
|
|
26294
26294
|
}
|
|
26295
26295
|
|
|
26296
26296
|
template <>
|
|
26297
|
-
idx_t SelectComparison<GreaterThan>(Vector &left, Vector &right,
|
|
26297
|
+
idx_t SelectComparison<GreaterThan>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
26298
26298
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
26299
|
-
return VectorOperations::
|
|
26299
|
+
return VectorOperations::DistinctGreaterThan(left, right, &sel, count, true_sel, false_sel);
|
|
26300
26300
|
}
|
|
26301
26301
|
|
|
26302
26302
|
template <>
|
|
26303
|
-
idx_t SelectComparison<GreaterThanEquals>(Vector &left, Vector &right,
|
|
26304
|
-
|
|
26305
|
-
return VectorOperations::
|
|
26303
|
+
idx_t SelectComparison<GreaterThanEquals>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
26304
|
+
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
26305
|
+
return VectorOperations::DistinctGreaterThanEquals(left, right, &sel, count, true_sel, false_sel);
|
|
26306
26306
|
}
|
|
26307
26307
|
|
|
26308
26308
|
template <>
|
|
26309
|
-
idx_t SelectComparison<LessThan>(Vector &left, Vector &right,
|
|
26309
|
+
idx_t SelectComparison<LessThan>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
26310
26310
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
26311
|
-
return VectorOperations::
|
|
26311
|
+
return VectorOperations::DistinctLessThan(left, right, &sel, count, true_sel, false_sel);
|
|
26312
26312
|
}
|
|
26313
26313
|
|
|
26314
26314
|
template <>
|
|
26315
|
-
idx_t SelectComparison<LessThanEquals>(Vector &left, Vector &right,
|
|
26316
|
-
|
|
26317
|
-
return VectorOperations::
|
|
26315
|
+
idx_t SelectComparison<LessThanEquals>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
26316
|
+
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
26317
|
+
return VectorOperations::DistinctLessThanEquals(left, right, &sel, count, true_sel, false_sel);
|
|
26318
26318
|
}
|
|
26319
26319
|
|
|
26320
26320
|
template <class T, class OP, bool NO_MATCH_SEL>
|
|
@@ -26380,9 +26380,8 @@ static void TemplatedMatchType(VectorData &col, Vector &rows, SelectionVector &s
|
|
|
26380
26380
|
}
|
|
26381
26381
|
|
|
26382
26382
|
template <class OP, bool NO_MATCH_SEL>
|
|
26383
|
-
static void TemplatedMatchNested(Vector &col, Vector &rows,
|
|
26384
|
-
const idx_t
|
|
26385
|
-
idx_t &no_match_count) {
|
|
26383
|
+
static void TemplatedMatchNested(Vector &col, Vector &rows, SelectionVector &sel, idx_t &count, const idx_t col_offset,
|
|
26384
|
+
const idx_t col_no, SelectionVector *no_match, idx_t &no_match_count) {
|
|
26386
26385
|
// Gather a dense Vector containing the column values being matched
|
|
26387
26386
|
Vector key(col.GetType());
|
|
26388
26387
|
RowOperations::Gather(rows, sel, key, *FlatVector::IncrementalSelectionVector(), count, col_offset, col_no);
|
|
@@ -26392,18 +26391,17 @@ static void TemplatedMatchNested(Vector &col, Vector &rows, const idx_t vcount,
|
|
|
26392
26391
|
|
|
26393
26392
|
if (NO_MATCH_SEL) {
|
|
26394
26393
|
SelectionVector no_match_sel_offset(no_match->data() + no_match_count);
|
|
26395
|
-
auto match_count = SelectComparison<OP>(sliced, key,
|
|
26394
|
+
auto match_count = SelectComparison<OP>(sliced, key, sel, count, &sel, &no_match_sel_offset);
|
|
26396
26395
|
no_match_count += count - match_count;
|
|
26397
26396
|
count = match_count;
|
|
26398
26397
|
} else {
|
|
26399
|
-
count = SelectComparison<OP>(sliced, key,
|
|
26398
|
+
count = SelectComparison<OP>(sliced, key, sel, count, &sel, nullptr);
|
|
26400
26399
|
}
|
|
26401
26400
|
}
|
|
26402
26401
|
|
|
26403
26402
|
template <class OP, bool NO_MATCH_SEL>
|
|
26404
|
-
static void TemplatedMatchOp(Vector &vec, VectorData &col, const
|
|
26405
|
-
|
|
26406
|
-
idx_t &no_match_count) {
|
|
26403
|
+
static void TemplatedMatchOp(Vector &vec, VectorData &col, const RowLayout &layout, Vector &rows, SelectionVector &sel,
|
|
26404
|
+
idx_t &count, idx_t col_no, SelectionVector *no_match, idx_t &no_match_count) {
|
|
26407
26405
|
if (count == 0) {
|
|
26408
26406
|
return;
|
|
26409
26407
|
}
|
|
@@ -26465,8 +26463,7 @@ static void TemplatedMatchOp(Vector &vec, VectorData &col, const idx_t vcount, c
|
|
|
26465
26463
|
case PhysicalType::LIST:
|
|
26466
26464
|
case PhysicalType::MAP:
|
|
26467
26465
|
case PhysicalType::STRUCT:
|
|
26468
|
-
TemplatedMatchNested<OP, NO_MATCH_SEL>(vec, rows,
|
|
26469
|
-
no_match_count);
|
|
26466
|
+
TemplatedMatchNested<OP, NO_MATCH_SEL>(vec, rows, sel, count, col_offset, col_no, no_match, no_match_count);
|
|
26470
26467
|
break;
|
|
26471
26468
|
default:
|
|
26472
26469
|
throw InternalException("Unsupported column type for RowOperations::Match");
|
|
@@ -26477,34 +26474,33 @@ template <bool NO_MATCH_SEL>
|
|
|
26477
26474
|
static void TemplatedMatch(DataChunk &columns, VectorData col_data[], const RowLayout &layout, Vector &rows,
|
|
26478
26475
|
const Predicates &predicates, SelectionVector &sel, idx_t &count, SelectionVector *no_match,
|
|
26479
26476
|
idx_t &no_match_count) {
|
|
26480
|
-
const idx_t vcount = columns.size();
|
|
26481
26477
|
for (idx_t col_no = 0; col_no < predicates.size(); ++col_no) {
|
|
26482
26478
|
auto &vec = columns.data[col_no];
|
|
26483
26479
|
auto &col = col_data[col_no];
|
|
26484
26480
|
switch (predicates[col_no]) {
|
|
26485
26481
|
case ExpressionType::COMPARE_EQUAL:
|
|
26486
26482
|
case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
|
|
26487
|
-
TemplatedMatchOp<Equals, NO_MATCH_SEL>(vec, col,
|
|
26483
|
+
TemplatedMatchOp<Equals, NO_MATCH_SEL>(vec, col, layout, rows, sel, count, col_no, no_match,
|
|
26488
26484
|
no_match_count);
|
|
26489
26485
|
break;
|
|
26490
26486
|
case ExpressionType::COMPARE_NOTEQUAL:
|
|
26491
|
-
TemplatedMatchOp<NotEquals, NO_MATCH_SEL>(vec, col,
|
|
26487
|
+
TemplatedMatchOp<NotEquals, NO_MATCH_SEL>(vec, col, layout, rows, sel, count, col_no, no_match,
|
|
26492
26488
|
no_match_count);
|
|
26493
26489
|
break;
|
|
26494
26490
|
case ExpressionType::COMPARE_GREATERTHAN:
|
|
26495
|
-
TemplatedMatchOp<GreaterThan, NO_MATCH_SEL>(vec, col,
|
|
26491
|
+
TemplatedMatchOp<GreaterThan, NO_MATCH_SEL>(vec, col, layout, rows, sel, count, col_no, no_match,
|
|
26496
26492
|
no_match_count);
|
|
26497
26493
|
break;
|
|
26498
26494
|
case ExpressionType::COMPARE_GREATERTHANOREQUALTO:
|
|
26499
|
-
TemplatedMatchOp<GreaterThanEquals, NO_MATCH_SEL>(vec, col,
|
|
26500
|
-
|
|
26495
|
+
TemplatedMatchOp<GreaterThanEquals, NO_MATCH_SEL>(vec, col, layout, rows, sel, count, col_no, no_match,
|
|
26496
|
+
no_match_count);
|
|
26501
26497
|
break;
|
|
26502
26498
|
case ExpressionType::COMPARE_LESSTHAN:
|
|
26503
|
-
TemplatedMatchOp<LessThan, NO_MATCH_SEL>(vec, col,
|
|
26499
|
+
TemplatedMatchOp<LessThan, NO_MATCH_SEL>(vec, col, layout, rows, sel, count, col_no, no_match,
|
|
26504
26500
|
no_match_count);
|
|
26505
26501
|
break;
|
|
26506
26502
|
case ExpressionType::COMPARE_LESSTHANOREQUALTO:
|
|
26507
|
-
TemplatedMatchOp<LessThanEquals, NO_MATCH_SEL>(vec, col,
|
|
26503
|
+
TemplatedMatchOp<LessThanEquals, NO_MATCH_SEL>(vec, col, layout, rows, sel, count, col_no, no_match,
|
|
26508
26504
|
no_match_count);
|
|
26509
26505
|
break;
|
|
26510
26506
|
default:
|
|
@@ -43336,7 +43332,7 @@ static void DistinctExecute(Vector &left, Vector &right, Vector &result, idx_t c
|
|
|
43336
43332
|
DistinctExecuteSwitch<LEFT_TYPE, RIGHT_TYPE, RESULT_TYPE, OP>(left, right, result, count);
|
|
43337
43333
|
}
|
|
43338
43334
|
|
|
43339
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool
|
|
43335
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool NO_NULL, bool HAS_TRUE_SEL, bool HAS_FALSE_SEL>
|
|
43340
43336
|
static inline idx_t
|
|
43341
43337
|
DistinctSelectGenericLoop(LEFT_TYPE *__restrict ldata, RIGHT_TYPE *__restrict rdata,
|
|
43342
43338
|
const SelectionVector *__restrict lsel, const SelectionVector *__restrict rsel,
|
|
@@ -43345,9 +43341,8 @@ DistinctSelectGenericLoop(LEFT_TYPE *__restrict ldata, RIGHT_TYPE *__restrict rd
|
|
|
43345
43341
|
idx_t true_count = 0, false_count = 0;
|
|
43346
43342
|
for (idx_t i = 0; i < count; i++) {
|
|
43347
43343
|
auto result_idx = result_sel->get_index(i);
|
|
43348
|
-
|
|
43349
|
-
auto
|
|
43350
|
-
auto rindex = rsel->get_index(idx);
|
|
43344
|
+
auto lindex = lsel->get_index(i);
|
|
43345
|
+
auto rindex = rsel->get_index(i);
|
|
43351
43346
|
if (NO_NULL) {
|
|
43352
43347
|
if (OP::Operation(ldata[lindex], rdata[rindex], false, false)) {
|
|
43353
43348
|
if (HAS_TRUE_SEL) {
|
|
@@ -43376,63 +43371,62 @@ DistinctSelectGenericLoop(LEFT_TYPE *__restrict ldata, RIGHT_TYPE *__restrict rd
|
|
|
43376
43371
|
return count - false_count;
|
|
43377
43372
|
}
|
|
43378
43373
|
}
|
|
43379
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool
|
|
43374
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool NO_NULL>
|
|
43380
43375
|
static inline idx_t
|
|
43381
43376
|
DistinctSelectGenericLoopSelSwitch(LEFT_TYPE *__restrict ldata, RIGHT_TYPE *__restrict rdata,
|
|
43382
43377
|
const SelectionVector *__restrict lsel, const SelectionVector *__restrict rsel,
|
|
43383
43378
|
const SelectionVector *__restrict result_sel, idx_t count, ValidityMask &lmask,
|
|
43384
43379
|
ValidityMask &rmask, SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
43385
43380
|
if (true_sel && false_sel) {
|
|
43386
|
-
return DistinctSelectGenericLoop<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43381
|
+
return DistinctSelectGenericLoop<LEFT_TYPE, RIGHT_TYPE, OP, NO_NULL, true, true>(
|
|
43387
43382
|
ldata, rdata, lsel, rsel, result_sel, count, lmask, rmask, true_sel, false_sel);
|
|
43388
43383
|
} else if (true_sel) {
|
|
43389
|
-
return DistinctSelectGenericLoop<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43384
|
+
return DistinctSelectGenericLoop<LEFT_TYPE, RIGHT_TYPE, OP, NO_NULL, true, false>(
|
|
43390
43385
|
ldata, rdata, lsel, rsel, result_sel, count, lmask, rmask, true_sel, false_sel);
|
|
43391
43386
|
} else {
|
|
43392
43387
|
D_ASSERT(false_sel);
|
|
43393
|
-
return DistinctSelectGenericLoop<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43388
|
+
return DistinctSelectGenericLoop<LEFT_TYPE, RIGHT_TYPE, OP, NO_NULL, false, true>(
|
|
43394
43389
|
ldata, rdata, lsel, rsel, result_sel, count, lmask, rmask, true_sel, false_sel);
|
|
43395
43390
|
}
|
|
43396
43391
|
}
|
|
43397
43392
|
|
|
43398
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP
|
|
43393
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP>
|
|
43399
43394
|
static inline idx_t
|
|
43400
43395
|
DistinctSelectGenericLoopSwitch(LEFT_TYPE *__restrict ldata, RIGHT_TYPE *__restrict rdata,
|
|
43401
43396
|
const SelectionVector *__restrict lsel, const SelectionVector *__restrict rsel,
|
|
43402
43397
|
const SelectionVector *__restrict result_sel, idx_t count, ValidityMask &lmask,
|
|
43403
43398
|
ValidityMask &rmask, SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
43404
43399
|
if (!lmask.AllValid() || !rmask.AllValid()) {
|
|
43405
|
-
return DistinctSelectGenericLoopSelSwitch<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43400
|
+
return DistinctSelectGenericLoopSelSwitch<LEFT_TYPE, RIGHT_TYPE, OP, false>(
|
|
43406
43401
|
ldata, rdata, lsel, rsel, result_sel, count, lmask, rmask, true_sel, false_sel);
|
|
43407
43402
|
} else {
|
|
43408
|
-
return DistinctSelectGenericLoopSelSwitch<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43403
|
+
return DistinctSelectGenericLoopSelSwitch<LEFT_TYPE, RIGHT_TYPE, OP, true>(
|
|
43409
43404
|
ldata, rdata, lsel, rsel, result_sel, count, lmask, rmask, true_sel, false_sel);
|
|
43410
43405
|
}
|
|
43411
43406
|
}
|
|
43412
43407
|
|
|
43413
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP
|
|
43414
|
-
static idx_t DistinctSelectGeneric(Vector &left, Vector &right,
|
|
43408
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP>
|
|
43409
|
+
static idx_t DistinctSelectGeneric(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
43415
43410
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
43416
43411
|
VectorData ldata, rdata;
|
|
43417
43412
|
|
|
43418
|
-
left.Orrify(
|
|
43419
|
-
right.Orrify(
|
|
43413
|
+
left.Orrify(count, ldata);
|
|
43414
|
+
right.Orrify(count, rdata);
|
|
43420
43415
|
|
|
43421
|
-
return DistinctSelectGenericLoopSwitch<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43422
|
-
|
|
43423
|
-
|
|
43416
|
+
return DistinctSelectGenericLoopSwitch<LEFT_TYPE, RIGHT_TYPE, OP>((LEFT_TYPE *)ldata.data, (RIGHT_TYPE *)rdata.data,
|
|
43417
|
+
ldata.sel, rdata.sel, sel, count, ldata.validity,
|
|
43418
|
+
rdata.validity, true_sel, false_sel);
|
|
43424
43419
|
}
|
|
43425
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool
|
|
43426
|
-
bool
|
|
43420
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool LEFT_CONSTANT, bool RIGHT_CONSTANT, bool NO_NULL,
|
|
43421
|
+
bool HAS_TRUE_SEL, bool HAS_FALSE_SEL>
|
|
43427
43422
|
static inline idx_t DistinctSelectFlatLoop(LEFT_TYPE *__restrict ldata, RIGHT_TYPE *__restrict rdata,
|
|
43428
43423
|
const SelectionVector *sel, idx_t count, ValidityMask &lmask,
|
|
43429
43424
|
ValidityMask &rmask, SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
43430
43425
|
idx_t true_count = 0, false_count = 0;
|
|
43431
43426
|
for (idx_t i = 0; i < count; i++) {
|
|
43432
43427
|
idx_t result_idx = sel->get_index(i);
|
|
43433
|
-
|
|
43434
|
-
idx_t
|
|
43435
|
-
idx_t ridx = RIGHT_CONSTANT ? 0 : idx;
|
|
43428
|
+
idx_t lidx = LEFT_CONSTANT ? 0 : i;
|
|
43429
|
+
idx_t ridx = RIGHT_CONSTANT ? 0 : i;
|
|
43436
43430
|
const bool lnull = !lmask.RowIsValid(lidx);
|
|
43437
43431
|
const bool rnull = !rmask.RowIsValid(ridx);
|
|
43438
43432
|
bool comparison_result = OP::Operation(ldata[lidx], rdata[ridx], lnull, rnull);
|
|
@@ -43452,34 +43446,33 @@ static inline idx_t DistinctSelectFlatLoop(LEFT_TYPE *__restrict ldata, RIGHT_TY
|
|
|
43452
43446
|
}
|
|
43453
43447
|
}
|
|
43454
43448
|
|
|
43455
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool
|
|
43456
|
-
bool NO_NULL>
|
|
43449
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool LEFT_CONSTANT, bool RIGHT_CONSTANT, bool NO_NULL>
|
|
43457
43450
|
static inline idx_t DistinctSelectFlatLoopSelSwitch(LEFT_TYPE *__restrict ldata, RIGHT_TYPE *__restrict rdata,
|
|
43458
43451
|
const SelectionVector *sel, idx_t count, ValidityMask &lmask,
|
|
43459
43452
|
ValidityMask &rmask, SelectionVector *true_sel,
|
|
43460
43453
|
SelectionVector *false_sel) {
|
|
43461
43454
|
if (true_sel && false_sel) {
|
|
43462
|
-
return DistinctSelectFlatLoop<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43463
|
-
|
|
43455
|
+
return DistinctSelectFlatLoop<LEFT_TYPE, RIGHT_TYPE, OP, LEFT_CONSTANT, RIGHT_CONSTANT, NO_NULL, true, true>(
|
|
43456
|
+
ldata, rdata, sel, count, lmask, rmask, true_sel, false_sel);
|
|
43464
43457
|
} else if (true_sel) {
|
|
43465
|
-
return DistinctSelectFlatLoop<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43466
|
-
|
|
43458
|
+
return DistinctSelectFlatLoop<LEFT_TYPE, RIGHT_TYPE, OP, LEFT_CONSTANT, RIGHT_CONSTANT, NO_NULL, true, false>(
|
|
43459
|
+
ldata, rdata, sel, count, lmask, rmask, true_sel, false_sel);
|
|
43467
43460
|
} else {
|
|
43468
43461
|
D_ASSERT(false_sel);
|
|
43469
|
-
return DistinctSelectFlatLoop<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43470
|
-
|
|
43462
|
+
return DistinctSelectFlatLoop<LEFT_TYPE, RIGHT_TYPE, OP, LEFT_CONSTANT, RIGHT_CONSTANT, NO_NULL, false, true>(
|
|
43463
|
+
ldata, rdata, sel, count, lmask, rmask, true_sel, false_sel);
|
|
43471
43464
|
}
|
|
43472
43465
|
}
|
|
43473
43466
|
|
|
43474
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool
|
|
43467
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool LEFT_CONSTANT, bool RIGHT_CONSTANT>
|
|
43475
43468
|
static inline idx_t DistinctSelectFlatLoopSwitch(LEFT_TYPE *__restrict ldata, RIGHT_TYPE *__restrict rdata,
|
|
43476
43469
|
const SelectionVector *sel, idx_t count, ValidityMask &lmask,
|
|
43477
43470
|
ValidityMask &rmask, SelectionVector *true_sel,
|
|
43478
43471
|
SelectionVector *false_sel) {
|
|
43479
|
-
return DistinctSelectFlatLoopSelSwitch<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43472
|
+
return DistinctSelectFlatLoopSelSwitch<LEFT_TYPE, RIGHT_TYPE, OP, LEFT_CONSTANT, RIGHT_CONSTANT, true>(
|
|
43480
43473
|
ldata, rdata, sel, count, lmask, rmask, true_sel, false_sel);
|
|
43481
43474
|
}
|
|
43482
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool
|
|
43475
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP, bool LEFT_CONSTANT, bool RIGHT_CONSTANT>
|
|
43483
43476
|
static idx_t DistinctSelectFlat(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
43484
43477
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
43485
43478
|
auto ldata = FlatVector::GetData<LEFT_TYPE>(left);
|
|
@@ -43489,17 +43482,17 @@ static idx_t DistinctSelectFlat(Vector &left, Vector &right, const SelectionVect
|
|
|
43489
43482
|
if (ConstantVector::IsNull(left)) {
|
|
43490
43483
|
validity.SetAllInvalid(1);
|
|
43491
43484
|
}
|
|
43492
|
-
return DistinctSelectFlatLoopSwitch<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43485
|
+
return DistinctSelectFlatLoopSwitch<LEFT_TYPE, RIGHT_TYPE, OP, LEFT_CONSTANT, RIGHT_CONSTANT>(
|
|
43493
43486
|
ldata, rdata, sel, count, validity, FlatVector::Validity(right), true_sel, false_sel);
|
|
43494
43487
|
} else if (RIGHT_CONSTANT) {
|
|
43495
43488
|
ValidityMask validity;
|
|
43496
43489
|
if (ConstantVector::IsNull(right)) {
|
|
43497
43490
|
validity.SetAllInvalid(1);
|
|
43498
43491
|
}
|
|
43499
|
-
return DistinctSelectFlatLoopSwitch<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43492
|
+
return DistinctSelectFlatLoopSwitch<LEFT_TYPE, RIGHT_TYPE, OP, LEFT_CONSTANT, RIGHT_CONSTANT>(
|
|
43500
43493
|
ldata, rdata, sel, count, FlatVector::Validity(left), validity, true_sel, false_sel);
|
|
43501
43494
|
} else {
|
|
43502
|
-
return DistinctSelectFlatLoopSwitch<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43495
|
+
return DistinctSelectFlatLoopSwitch<LEFT_TYPE, RIGHT_TYPE, OP, LEFT_CONSTANT, RIGHT_CONSTANT>(
|
|
43503
43496
|
ldata, rdata, sel, count, FlatVector::Validity(left), FlatVector::Validity(right), true_sel, false_sel);
|
|
43504
43497
|
}
|
|
43505
43498
|
}
|
|
@@ -43528,8 +43521,8 @@ static idx_t DistinctSelectConstant(Vector &left, Vector &right, const Selection
|
|
|
43528
43521
|
}
|
|
43529
43522
|
}
|
|
43530
43523
|
|
|
43531
|
-
template <class LEFT_TYPE, class RIGHT_TYPE, class OP
|
|
43532
|
-
static idx_t DistinctSelect(Vector &left, Vector &right,
|
|
43524
|
+
template <class LEFT_TYPE, class RIGHT_TYPE, class OP>
|
|
43525
|
+
static idx_t DistinctSelect(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
43533
43526
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
43534
43527
|
SelectionVector owned_sel;
|
|
43535
43528
|
if (!sel) {
|
|
@@ -43539,18 +43532,15 @@ static idx_t DistinctSelect(Vector &left, Vector &right, idx_t vcount, const Sel
|
|
|
43539
43532
|
return DistinctSelectConstant<LEFT_TYPE, RIGHT_TYPE, OP>(left, right, sel, count, true_sel, false_sel);
|
|
43540
43533
|
} else if (left.GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
43541
43534
|
right.GetVectorType() == VectorType::FLAT_VECTOR) {
|
|
43542
|
-
return DistinctSelectFlat<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43543
|
-
false_sel);
|
|
43535
|
+
return DistinctSelectFlat<LEFT_TYPE, RIGHT_TYPE, OP, true, false>(left, right, sel, count, true_sel, false_sel);
|
|
43544
43536
|
} else if (left.GetVectorType() == VectorType::FLAT_VECTOR &&
|
|
43545
43537
|
right.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
43546
|
-
return DistinctSelectFlat<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43547
|
-
false_sel);
|
|
43538
|
+
return DistinctSelectFlat<LEFT_TYPE, RIGHT_TYPE, OP, false, true>(left, right, sel, count, true_sel, false_sel);
|
|
43548
43539
|
} else if (left.GetVectorType() == VectorType::FLAT_VECTOR && right.GetVectorType() == VectorType::FLAT_VECTOR) {
|
|
43549
|
-
return DistinctSelectFlat<LEFT_TYPE, RIGHT_TYPE, OP,
|
|
43550
|
-
|
|
43540
|
+
return DistinctSelectFlat<LEFT_TYPE, RIGHT_TYPE, OP, false, false>(left, right, sel, count, true_sel,
|
|
43541
|
+
false_sel);
|
|
43551
43542
|
} else {
|
|
43552
|
-
return DistinctSelectGeneric<LEFT_TYPE, RIGHT_TYPE, OP
|
|
43553
|
-
false_sel);
|
|
43543
|
+
return DistinctSelectGeneric<LEFT_TYPE, RIGHT_TYPE, OP>(left, right, sel, count, true_sel, false_sel);
|
|
43554
43544
|
}
|
|
43555
43545
|
}
|
|
43556
43546
|
|
|
@@ -43614,24 +43604,24 @@ struct PositionComparator {
|
|
|
43614
43604
|
// Select the rows that definitely match.
|
|
43615
43605
|
// Default to the same as the final row
|
|
43616
43606
|
template <typename OP>
|
|
43617
|
-
static idx_t Definite(Vector &left, Vector &right,
|
|
43607
|
+
static idx_t Definite(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
43618
43608
|
SelectionVector *true_sel, SelectionVector &false_sel) {
|
|
43619
|
-
return Final<OP>(left, right,
|
|
43609
|
+
return Final<OP>(left, right, sel, count, true_sel, &false_sel);
|
|
43620
43610
|
}
|
|
43621
43611
|
|
|
43622
43612
|
// Select the possible rows that need further testing.
|
|
43623
43613
|
// Usually this means Is Not Distinct, as those are the semantics used by Postges
|
|
43624
43614
|
template <typename OP>
|
|
43625
|
-
static idx_t Possible(Vector &left, Vector &right,
|
|
43615
|
+
static idx_t Possible(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
43626
43616
|
SelectionVector &true_sel, SelectionVector *false_sel) {
|
|
43627
|
-
return VectorOperations::NestedEquals(left, right,
|
|
43617
|
+
return VectorOperations::NestedEquals(left, right, sel, count, &true_sel, false_sel);
|
|
43628
43618
|
}
|
|
43629
43619
|
|
|
43630
43620
|
// Select the matching rows for the final position.
|
|
43631
43621
|
// This needs to be specialised.
|
|
43632
43622
|
template <typename OP>
|
|
43633
|
-
static idx_t Final(Vector &left, Vector &right,
|
|
43634
|
-
SelectionVector *
|
|
43623
|
+
static idx_t Final(Vector &left, Vector &right, const SelectionVector &sel, idx_t count, SelectionVector *true_sel,
|
|
43624
|
+
SelectionVector *false_sel) {
|
|
43635
43625
|
return 0;
|
|
43636
43626
|
}
|
|
43637
43627
|
|
|
@@ -43646,90 +43636,90 @@ struct PositionComparator {
|
|
|
43646
43636
|
|
|
43647
43637
|
// NotDistinctFrom must always check every column
|
|
43648
43638
|
template <>
|
|
43649
|
-
idx_t PositionComparator::Definite<duckdb::NotDistinctFrom>(Vector &left, Vector &right,
|
|
43650
|
-
|
|
43651
|
-
SelectionVector
|
|
43639
|
+
idx_t PositionComparator::Definite<duckdb::NotDistinctFrom>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
43640
|
+
idx_t count, SelectionVector *true_sel,
|
|
43641
|
+
SelectionVector &false_sel) {
|
|
43652
43642
|
return 0;
|
|
43653
43643
|
}
|
|
43654
43644
|
|
|
43655
43645
|
template <>
|
|
43656
|
-
idx_t PositionComparator::Final<duckdb::NotDistinctFrom>(Vector &left, Vector &right,
|
|
43657
|
-
|
|
43658
|
-
SelectionVector *
|
|
43659
|
-
return VectorOperations::NestedEquals(left, right,
|
|
43646
|
+
idx_t PositionComparator::Final<duckdb::NotDistinctFrom>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
43647
|
+
idx_t count, SelectionVector *true_sel,
|
|
43648
|
+
SelectionVector *false_sel) {
|
|
43649
|
+
return VectorOperations::NestedEquals(left, right, sel, count, true_sel, false_sel);
|
|
43660
43650
|
}
|
|
43661
43651
|
|
|
43662
43652
|
// DistinctFrom must check everything that matched
|
|
43663
43653
|
template <>
|
|
43664
|
-
idx_t PositionComparator::Possible<duckdb::DistinctFrom>(Vector &left, Vector &right,
|
|
43665
|
-
|
|
43666
|
-
SelectionVector
|
|
43654
|
+
idx_t PositionComparator::Possible<duckdb::DistinctFrom>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
43655
|
+
idx_t count, SelectionVector &true_sel,
|
|
43656
|
+
SelectionVector *false_sel) {
|
|
43667
43657
|
return count;
|
|
43668
43658
|
}
|
|
43669
43659
|
|
|
43670
43660
|
template <>
|
|
43671
|
-
idx_t PositionComparator::Final<duckdb::DistinctFrom>(Vector &left, Vector &right,
|
|
43672
|
-
|
|
43673
|
-
SelectionVector *
|
|
43674
|
-
return VectorOperations::NestedNotEquals(left, right,
|
|
43661
|
+
idx_t PositionComparator::Final<duckdb::DistinctFrom>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
43662
|
+
idx_t count, SelectionVector *true_sel,
|
|
43663
|
+
SelectionVector *false_sel) {
|
|
43664
|
+
return VectorOperations::NestedNotEquals(left, right, sel, count, true_sel, false_sel);
|
|
43675
43665
|
}
|
|
43676
43666
|
|
|
43677
43667
|
// Non-strict inequalities must use strict comparisons for Definite
|
|
43678
43668
|
template <>
|
|
43679
|
-
idx_t PositionComparator::Definite<duckdb::DistinctLessThanEquals>(Vector &left, Vector &right,
|
|
43669
|
+
idx_t PositionComparator::Definite<duckdb::DistinctLessThanEquals>(Vector &left, Vector &right,
|
|
43680
43670
|
const SelectionVector &sel, idx_t count,
|
|
43681
43671
|
SelectionVector *true_sel,
|
|
43682
43672
|
SelectionVector &false_sel) {
|
|
43683
|
-
return VectorOperations::
|
|
43673
|
+
return VectorOperations::DistinctLessThan(left, right, &sel, count, true_sel, &false_sel);
|
|
43684
43674
|
}
|
|
43685
43675
|
|
|
43686
43676
|
template <>
|
|
43687
|
-
idx_t PositionComparator::Final<duckdb::DistinctLessThanEquals>(Vector &left, Vector &right,
|
|
43688
|
-
|
|
43689
|
-
SelectionVector *
|
|
43690
|
-
return VectorOperations::
|
|
43677
|
+
idx_t PositionComparator::Final<duckdb::DistinctLessThanEquals>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
43678
|
+
idx_t count, SelectionVector *true_sel,
|
|
43679
|
+
SelectionVector *false_sel) {
|
|
43680
|
+
return VectorOperations::DistinctLessThanEquals(left, right, &sel, count, true_sel, false_sel);
|
|
43691
43681
|
}
|
|
43692
43682
|
|
|
43693
43683
|
template <>
|
|
43694
|
-
idx_t PositionComparator::Definite<duckdb::DistinctGreaterThanEquals>(Vector &left, Vector &right,
|
|
43684
|
+
idx_t PositionComparator::Definite<duckdb::DistinctGreaterThanEquals>(Vector &left, Vector &right,
|
|
43695
43685
|
const SelectionVector &sel, idx_t count,
|
|
43696
43686
|
SelectionVector *true_sel,
|
|
43697
43687
|
SelectionVector &false_sel) {
|
|
43698
|
-
return VectorOperations::
|
|
43688
|
+
return VectorOperations::DistinctGreaterThan(left, right, &sel, count, true_sel, &false_sel);
|
|
43699
43689
|
}
|
|
43700
43690
|
|
|
43701
43691
|
template <>
|
|
43702
|
-
idx_t PositionComparator::Final<duckdb::DistinctGreaterThanEquals>(Vector &left, Vector &right,
|
|
43692
|
+
idx_t PositionComparator::Final<duckdb::DistinctGreaterThanEquals>(Vector &left, Vector &right,
|
|
43703
43693
|
const SelectionVector &sel, idx_t count,
|
|
43704
43694
|
SelectionVector *true_sel,
|
|
43705
43695
|
SelectionVector *false_sel) {
|
|
43706
|
-
return VectorOperations::
|
|
43696
|
+
return VectorOperations::DistinctGreaterThanEquals(left, right, &sel, count, true_sel, false_sel);
|
|
43707
43697
|
}
|
|
43708
43698
|
|
|
43709
43699
|
// Strict inequalities just use strict for both Definite and Final
|
|
43710
43700
|
template <>
|
|
43711
|
-
idx_t PositionComparator::Final<duckdb::DistinctLessThan>(Vector &left, Vector &right,
|
|
43712
|
-
|
|
43713
|
-
SelectionVector *
|
|
43714
|
-
return VectorOperations::
|
|
43701
|
+
idx_t PositionComparator::Final<duckdb::DistinctLessThan>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
43702
|
+
idx_t count, SelectionVector *true_sel,
|
|
43703
|
+
SelectionVector *false_sel) {
|
|
43704
|
+
return VectorOperations::DistinctLessThan(left, right, &sel, count, true_sel, false_sel);
|
|
43715
43705
|
}
|
|
43716
43706
|
|
|
43717
43707
|
template <>
|
|
43718
|
-
idx_t PositionComparator::Final<duckdb::DistinctGreaterThan>(Vector &left, Vector &right,
|
|
43719
|
-
|
|
43720
|
-
SelectionVector *
|
|
43721
|
-
return VectorOperations::
|
|
43708
|
+
idx_t PositionComparator::Final<duckdb::DistinctGreaterThan>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
43709
|
+
idx_t count, SelectionVector *true_sel,
|
|
43710
|
+
SelectionVector *false_sel) {
|
|
43711
|
+
return VectorOperations::DistinctGreaterThan(left, right, &sel, count, true_sel, false_sel);
|
|
43722
43712
|
}
|
|
43723
43713
|
|
|
43724
43714
|
using StructEntries = vector<unique_ptr<Vector>>;
|
|
43725
43715
|
|
|
43726
|
-
static StructEntries &StructVectorGetSlicedEntries(Vector &parent, StructEntries &sliced, const idx_t
|
|
43716
|
+
static StructEntries &StructVectorGetSlicedEntries(Vector &parent, StructEntries &sliced, const idx_t count) {
|
|
43727
43717
|
// We have to manually slice STRUCT dictionaries.
|
|
43728
43718
|
auto &children = StructVector::GetEntries(parent);
|
|
43729
43719
|
if (parent.GetVectorType() == VectorType::DICTIONARY_VECTOR) {
|
|
43730
43720
|
auto &dict_sel = DictionaryVector::SelVector(parent);
|
|
43731
43721
|
for (auto &child : children) {
|
|
43732
|
-
auto v = make_unique<Vector>(*child, dict_sel,
|
|
43722
|
+
auto v = make_unique<Vector>(*child, dict_sel, count);
|
|
43733
43723
|
sliced.push_back(move(v));
|
|
43734
43724
|
}
|
|
43735
43725
|
|
|
@@ -43792,8 +43782,7 @@ static idx_t DistinctSelectStruct(Vector &left, Vector &right, idx_t count, cons
|
|
|
43792
43782
|
rchild.Slice(slice_sel, count);
|
|
43793
43783
|
|
|
43794
43784
|
// Find everything that definitely matches
|
|
43795
|
-
auto true_count =
|
|
43796
|
-
PositionComparator::Definite<OP>(lchild, rchild, count, slice_sel, count, &true_sel, false_sel);
|
|
43785
|
+
auto true_count = PositionComparator::Definite<OP>(lchild, rchild, slice_sel, count, &true_sel, false_sel);
|
|
43797
43786
|
if (true_count > 0) {
|
|
43798
43787
|
auto false_count = count - true_count;
|
|
43799
43788
|
|
|
@@ -43809,8 +43798,7 @@ static idx_t DistinctSelectStruct(Vector &left, Vector &right, idx_t count, cons
|
|
|
43809
43798
|
|
|
43810
43799
|
if (col_no != lchildren.size() - 1) {
|
|
43811
43800
|
// Find what might match on the next position
|
|
43812
|
-
true_count =
|
|
43813
|
-
PositionComparator::Possible<OP>(lchild, rchild, count, slice_sel, count, true_sel, &false_sel);
|
|
43801
|
+
true_count = PositionComparator::Possible<OP>(lchild, rchild, slice_sel, count, true_sel, &false_sel);
|
|
43814
43802
|
auto false_count = count - true_count;
|
|
43815
43803
|
|
|
43816
43804
|
// Extract the definite failures into the false result
|
|
@@ -43823,7 +43811,7 @@ static idx_t DistinctSelectStruct(Vector &left, Vector &right, idx_t count, cons
|
|
|
43823
43811
|
|
|
43824
43812
|
count = true_count;
|
|
43825
43813
|
} else {
|
|
43826
|
-
true_count = PositionComparator::Final<OP>(lchild, rchild,
|
|
43814
|
+
true_count = PositionComparator::Final<OP>(lchild, rchild, slice_sel, count, &true_sel, &false_sel);
|
|
43827
43815
|
auto false_count = count - true_count;
|
|
43828
43816
|
|
|
43829
43817
|
// Extract the definite matches into the true result
|
|
@@ -43938,7 +43926,7 @@ static idx_t DistinctSelectList(Vector &left, Vector &right, idx_t count, const
|
|
|
43938
43926
|
}
|
|
43939
43927
|
|
|
43940
43928
|
// Find everything that definitely matches
|
|
43941
|
-
true_count = PositionComparator::Definite<OP>(lchild, rchild,
|
|
43929
|
+
true_count = PositionComparator::Definite<OP>(lchild, rchild, slice_sel, count, &true_sel, false_sel);
|
|
43942
43930
|
if (true_count) {
|
|
43943
43931
|
false_count = count - true_count;
|
|
43944
43932
|
ExtractNestedSelection(false_count ? true_sel : slice_sel, true_count, sel, true_opt);
|
|
@@ -43952,7 +43940,7 @@ static idx_t DistinctSelectList(Vector &left, Vector &right, idx_t count, const
|
|
|
43952
43940
|
}
|
|
43953
43941
|
|
|
43954
43942
|
// Find what might match on the next position
|
|
43955
|
-
true_count = PositionComparator::Possible<OP>(lchild, rchild,
|
|
43943
|
+
true_count = PositionComparator::Possible<OP>(lchild, rchild, slice_sel, count, true_sel, &false_sel);
|
|
43956
43944
|
false_count = count - true_count;
|
|
43957
43945
|
ExtractNestedSelection(true_count ? false_sel : slice_sel, false_count, sel, false_opt);
|
|
43958
43946
|
|
|
@@ -44075,38 +44063,38 @@ static void ExecuteDistinct(Vector &left, Vector &right, Vector &result, idx_t c
|
|
|
44075
44063
|
}
|
|
44076
44064
|
}
|
|
44077
44065
|
|
|
44078
|
-
template <class OP,
|
|
44079
|
-
static idx_t TemplatedDistinctSelectOperation(Vector &left, Vector &right,
|
|
44080
|
-
|
|
44066
|
+
template <class OP, class OPNESTED = OP>
|
|
44067
|
+
static idx_t TemplatedDistinctSelectOperation(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
44068
|
+
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44081
44069
|
// the inplace loops take the result as the last parameter
|
|
44082
44070
|
switch (left.GetType().InternalType()) {
|
|
44083
44071
|
case PhysicalType::BOOL:
|
|
44084
44072
|
case PhysicalType::INT8:
|
|
44085
|
-
return DistinctSelect<int8_t, int8_t, OP
|
|
44073
|
+
return DistinctSelect<int8_t, int8_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44086
44074
|
case PhysicalType::INT16:
|
|
44087
|
-
return DistinctSelect<int16_t, int16_t, OP
|
|
44075
|
+
return DistinctSelect<int16_t, int16_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44088
44076
|
case PhysicalType::INT32:
|
|
44089
|
-
return DistinctSelect<int32_t, int32_t, OP
|
|
44077
|
+
return DistinctSelect<int32_t, int32_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44090
44078
|
case PhysicalType::INT64:
|
|
44091
|
-
return DistinctSelect<int64_t, int64_t, OP
|
|
44079
|
+
return DistinctSelect<int64_t, int64_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44092
44080
|
case PhysicalType::UINT8:
|
|
44093
|
-
return DistinctSelect<uint8_t, uint8_t, OP
|
|
44081
|
+
return DistinctSelect<uint8_t, uint8_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44094
44082
|
case PhysicalType::UINT16:
|
|
44095
|
-
return DistinctSelect<uint16_t, uint16_t, OP
|
|
44083
|
+
return DistinctSelect<uint16_t, uint16_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44096
44084
|
case PhysicalType::UINT32:
|
|
44097
|
-
return DistinctSelect<uint32_t, uint32_t, OP
|
|
44085
|
+
return DistinctSelect<uint32_t, uint32_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44098
44086
|
case PhysicalType::UINT64:
|
|
44099
|
-
return DistinctSelect<uint64_t, uint64_t, OP
|
|
44087
|
+
return DistinctSelect<uint64_t, uint64_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44100
44088
|
case PhysicalType::INT128:
|
|
44101
|
-
return DistinctSelect<hugeint_t, hugeint_t, OP
|
|
44089
|
+
return DistinctSelect<hugeint_t, hugeint_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44102
44090
|
case PhysicalType::FLOAT:
|
|
44103
|
-
return DistinctSelect<float, float, OP
|
|
44091
|
+
return DistinctSelect<float, float, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44104
44092
|
case PhysicalType::DOUBLE:
|
|
44105
|
-
return DistinctSelect<double, double, OP
|
|
44093
|
+
return DistinctSelect<double, double, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44106
44094
|
case PhysicalType::INTERVAL:
|
|
44107
|
-
return DistinctSelect<interval_t, interval_t, OP
|
|
44095
|
+
return DistinctSelect<interval_t, interval_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44108
44096
|
case PhysicalType::VARCHAR:
|
|
44109
|
-
return DistinctSelect<string_t, string_t, OP
|
|
44097
|
+
return DistinctSelect<string_t, string_t, OP>(left, right, sel, count, true_sel, false_sel);
|
|
44110
44098
|
case PhysicalType::MAP:
|
|
44111
44099
|
case PhysicalType::STRUCT:
|
|
44112
44100
|
case PhysicalType::LIST:
|
|
@@ -44126,7 +44114,7 @@ static void NestedDistinctExecute(Vector &left, Vector &right, Vector &result, i
|
|
|
44126
44114
|
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
44127
44115
|
auto result_data = ConstantVector::GetData<bool>(result);
|
|
44128
44116
|
SelectionVector true_sel(1);
|
|
44129
|
-
auto match_count = TemplatedDistinctSelectOperation<OP
|
|
44117
|
+
auto match_count = TemplatedDistinctSelectOperation<OP>(left, right, nullptr, 1, &true_sel, nullptr);
|
|
44130
44118
|
result_data[0] = match_count > 0;
|
|
44131
44119
|
return;
|
|
44132
44120
|
}
|
|
@@ -44135,8 +44123,7 @@ static void NestedDistinctExecute(Vector &left, Vector &right, Vector &result, i
|
|
|
44135
44123
|
SelectionVector false_sel(count);
|
|
44136
44124
|
|
|
44137
44125
|
// DISTINCT is either true or false
|
|
44138
|
-
idx_t match_count =
|
|
44139
|
-
TemplatedDistinctSelectOperation<OP, true>(left, right, count, nullptr, count, &true_sel, &false_sel);
|
|
44126
|
+
idx_t match_count = TemplatedDistinctSelectOperation<OP>(left, right, nullptr, count, &true_sel, &false_sel);
|
|
44140
44127
|
|
|
44141
44128
|
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
44142
44129
|
auto result_data = FlatVector::GetData<bool>(result);
|
|
@@ -44164,92 +44151,62 @@ void VectorOperations::NotDistinctFrom(Vector &left, Vector &right, Vector &resu
|
|
|
44164
44151
|
// true := A != B with nulls being equal
|
|
44165
44152
|
idx_t VectorOperations::DistinctFrom(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
44166
44153
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44167
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctFrom
|
|
44168
|
-
false_sel);
|
|
44154
|
+
return TemplatedDistinctSelectOperation<duckdb::DistinctFrom>(left, right, sel, count, true_sel, false_sel);
|
|
44169
44155
|
}
|
|
44170
44156
|
// true := A == B with nulls being equal
|
|
44171
44157
|
idx_t VectorOperations::NotDistinctFrom(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
44172
44158
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44173
|
-
return TemplatedDistinctSelectOperation<duckdb::NotDistinctFrom
|
|
44174
|
-
false_sel);
|
|
44159
|
+
return TemplatedDistinctSelectOperation<duckdb::NotDistinctFrom>(left, right, sel, count, true_sel, false_sel);
|
|
44175
44160
|
}
|
|
44176
44161
|
|
|
44177
44162
|
// true := A > B with nulls being maximal
|
|
44178
44163
|
idx_t VectorOperations::DistinctGreaterThan(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
44179
44164
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44180
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThan
|
|
44181
|
-
false_sel);
|
|
44165
|
+
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThan>(left, right, sel, count, true_sel, false_sel);
|
|
44182
44166
|
}
|
|
44183
44167
|
|
|
44184
44168
|
// true := A > B with nulls being minimal
|
|
44185
44169
|
idx_t VectorOperations::DistinctGreaterThanNullsFirst(Vector &left, Vector &right, const SelectionVector *sel,
|
|
44186
44170
|
idx_t count, SelectionVector *true_sel,
|
|
44187
44171
|
SelectionVector *false_sel) {
|
|
44188
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanNullsFirst,
|
|
44189
|
-
left, right,
|
|
44172
|
+
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanNullsFirst, duckdb::DistinctGreaterThan>(
|
|
44173
|
+
left, right, sel, count, true_sel, false_sel);
|
|
44190
44174
|
}
|
|
44191
44175
|
// true := A >= B with nulls being maximal
|
|
44192
44176
|
idx_t VectorOperations::DistinctGreaterThanEquals(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
44193
44177
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44194
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanEquals
|
|
44195
|
-
|
|
44178
|
+
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanEquals>(left, right, sel, count, true_sel,
|
|
44179
|
+
false_sel);
|
|
44196
44180
|
}
|
|
44197
44181
|
// true := A < B with nulls being maximal
|
|
44198
44182
|
idx_t VectorOperations::DistinctLessThan(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
44199
44183
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44200
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctLessThan
|
|
44201
|
-
false_sel);
|
|
44184
|
+
return TemplatedDistinctSelectOperation<duckdb::DistinctLessThan>(left, right, sel, count, true_sel, false_sel);
|
|
44202
44185
|
}
|
|
44203
44186
|
|
|
44204
44187
|
// true := A < B with nulls being minimal
|
|
44205
44188
|
idx_t VectorOperations::DistinctLessThanNullsFirst(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
44206
44189
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44207
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctLessThanNullsFirst,
|
|
44208
|
-
left, right,
|
|
44190
|
+
return TemplatedDistinctSelectOperation<duckdb::DistinctLessThanNullsFirst, duckdb::DistinctLessThan>(
|
|
44191
|
+
left, right, sel, count, true_sel, false_sel);
|
|
44209
44192
|
}
|
|
44210
44193
|
|
|
44211
44194
|
// true := A <= B with nulls being maximal
|
|
44212
44195
|
idx_t VectorOperations::DistinctLessThanEquals(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
|
|
44213
44196
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44214
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctLessThanEquals
|
|
44215
|
-
|
|
44197
|
+
return TemplatedDistinctSelectOperation<duckdb::DistinctLessThanEquals>(left, right, sel, count, true_sel,
|
|
44198
|
+
false_sel);
|
|
44216
44199
|
}
|
|
44217
44200
|
|
|
44218
44201
|
// true := A != B with nulls being equal, inputs selected
|
|
44219
|
-
idx_t VectorOperations::NestedNotEquals(Vector &left, Vector &right,
|
|
44220
|
-
|
|
44221
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctFrom
|
|
44222
|
-
false_sel);
|
|
44202
|
+
idx_t VectorOperations::NestedNotEquals(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
44203
|
+
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44204
|
+
return TemplatedDistinctSelectOperation<duckdb::DistinctFrom>(left, right, &sel, count, true_sel, false_sel);
|
|
44223
44205
|
}
|
|
44224
44206
|
// true := A == B with nulls being equal, inputs selected
|
|
44225
|
-
idx_t VectorOperations::NestedEquals(Vector &left, Vector &right,
|
|
44207
|
+
idx_t VectorOperations::NestedEquals(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
44226
44208
|
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44227
|
-
return TemplatedDistinctSelectOperation<duckdb::NotDistinctFrom
|
|
44228
|
-
false_sel);
|
|
44229
|
-
}
|
|
44230
|
-
// true := A > B with nulls being maximal, inputs selected
|
|
44231
|
-
idx_t VectorOperations::NestedGreaterThan(Vector &left, Vector &right, idx_t vcount, const SelectionVector &sel,
|
|
44232
|
-
idx_t count, SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44233
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThan, true>(left, right, vcount, &sel, count,
|
|
44234
|
-
true_sel, false_sel);
|
|
44235
|
-
}
|
|
44236
|
-
// true := A >= B with nulls being maximal, inputs selected
|
|
44237
|
-
idx_t VectorOperations::NestedGreaterThanEquals(Vector &left, Vector &right, idx_t vcount, const SelectionVector &sel,
|
|
44238
|
-
idx_t count, SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44239
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanEquals, true>(left, right, vcount, &sel, count,
|
|
44240
|
-
true_sel, false_sel);
|
|
44241
|
-
}
|
|
44242
|
-
// true := A < B with nulls being maximal, inputs selected
|
|
44243
|
-
idx_t VectorOperations::NestedLessThan(Vector &left, Vector &right, idx_t vcount, const SelectionVector &sel,
|
|
44244
|
-
idx_t count, SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44245
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctLessThan, true>(left, right, vcount, &sel, count, true_sel,
|
|
44246
|
-
false_sel);
|
|
44247
|
-
}
|
|
44248
|
-
// true := A <= B with nulls being maximal, inputs selected
|
|
44249
|
-
idx_t VectorOperations::NestedLessThanEquals(Vector &left, Vector &right, idx_t vcount, const SelectionVector &sel,
|
|
44250
|
-
idx_t count, SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
44251
|
-
return TemplatedDistinctSelectOperation<duckdb::DistinctLessThanEquals, true>(left, right, vcount, &sel, count,
|
|
44252
|
-
true_sel, false_sel);
|
|
44209
|
+
return TemplatedDistinctSelectOperation<duckdb::NotDistinctFrom>(left, right, &sel, count, true_sel, false_sel);
|
|
44253
44210
|
}
|
|
44254
44211
|
|
|
44255
44212
|
} // namespace duckdb
|
|
@@ -48320,48 +48277,48 @@ struct NestedSelector {
|
|
|
48320
48277
|
// Select the matching rows for the values of a nested type that are not both NULL.
|
|
48321
48278
|
// Those semantics are the same as the corresponding non-distinct comparator
|
|
48322
48279
|
template <typename OP>
|
|
48323
|
-
static idx_t Select(Vector &left, Vector &right,
|
|
48324
|
-
SelectionVector *
|
|
48280
|
+
static idx_t Select(Vector &left, Vector &right, const SelectionVector &sel, idx_t count, SelectionVector *true_sel,
|
|
48281
|
+
SelectionVector *false_sel) {
|
|
48325
48282
|
throw InvalidTypeException(left.GetType(), "Invalid operation for nested SELECT");
|
|
48326
48283
|
}
|
|
48327
48284
|
};
|
|
48328
48285
|
|
|
48329
48286
|
template <>
|
|
48330
|
-
idx_t NestedSelector::Select<duckdb::Equals>(Vector &left, Vector &right,
|
|
48331
|
-
|
|
48332
|
-
return VectorOperations::NestedEquals(left, right,
|
|
48287
|
+
idx_t NestedSelector::Select<duckdb::Equals>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
48288
|
+
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
48289
|
+
return VectorOperations::NestedEquals(left, right, sel, count, true_sel, false_sel);
|
|
48333
48290
|
}
|
|
48334
48291
|
|
|
48335
48292
|
template <>
|
|
48336
|
-
idx_t NestedSelector::Select<duckdb::NotEquals>(Vector &left, Vector &right,
|
|
48337
|
-
|
|
48338
|
-
return VectorOperations::NestedNotEquals(left, right,
|
|
48293
|
+
idx_t NestedSelector::Select<duckdb::NotEquals>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
48294
|
+
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
48295
|
+
return VectorOperations::NestedNotEquals(left, right, sel, count, true_sel, false_sel);
|
|
48339
48296
|
}
|
|
48340
48297
|
|
|
48341
48298
|
template <>
|
|
48342
|
-
idx_t NestedSelector::Select<duckdb::LessThan>(Vector &left, Vector &right,
|
|
48343
|
-
|
|
48344
|
-
return VectorOperations::
|
|
48299
|
+
idx_t NestedSelector::Select<duckdb::LessThan>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
48300
|
+
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
48301
|
+
return VectorOperations::DistinctLessThan(left, right, &sel, count, true_sel, false_sel);
|
|
48345
48302
|
}
|
|
48346
48303
|
|
|
48347
48304
|
template <>
|
|
48348
|
-
idx_t NestedSelector::Select<duckdb::LessThanEquals>(Vector &left, Vector &right,
|
|
48349
|
-
|
|
48305
|
+
idx_t NestedSelector::Select<duckdb::LessThanEquals>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
48306
|
+
idx_t count, SelectionVector *true_sel,
|
|
48350
48307
|
SelectionVector *false_sel) {
|
|
48351
|
-
return VectorOperations::
|
|
48308
|
+
return VectorOperations::DistinctLessThanEquals(left, right, &sel, count, true_sel, false_sel);
|
|
48352
48309
|
}
|
|
48353
48310
|
|
|
48354
48311
|
template <>
|
|
48355
|
-
idx_t NestedSelector::Select<duckdb::GreaterThan>(Vector &left, Vector &right,
|
|
48356
|
-
|
|
48357
|
-
return VectorOperations::
|
|
48312
|
+
idx_t NestedSelector::Select<duckdb::GreaterThan>(Vector &left, Vector &right, const SelectionVector &sel, idx_t count,
|
|
48313
|
+
SelectionVector *true_sel, SelectionVector *false_sel) {
|
|
48314
|
+
return VectorOperations::DistinctGreaterThan(left, right, &sel, count, true_sel, false_sel);
|
|
48358
48315
|
}
|
|
48359
48316
|
|
|
48360
48317
|
template <>
|
|
48361
|
-
idx_t NestedSelector::Select<duckdb::GreaterThanEquals>(Vector &left, Vector &right,
|
|
48362
|
-
|
|
48363
|
-
SelectionVector *
|
|
48364
|
-
return VectorOperations::
|
|
48318
|
+
idx_t NestedSelector::Select<duckdb::GreaterThanEquals>(Vector &left, Vector &right, const SelectionVector &sel,
|
|
48319
|
+
idx_t count, SelectionVector *true_sel,
|
|
48320
|
+
SelectionVector *false_sel) {
|
|
48321
|
+
return VectorOperations::DistinctGreaterThanEquals(left, right, &sel, count, true_sel, false_sel);
|
|
48365
48322
|
}
|
|
48366
48323
|
|
|
48367
48324
|
static inline idx_t SelectNotNull(Vector &left, Vector &right, const idx_t count, const SelectionVector &sel,
|
|
@@ -48450,7 +48407,7 @@ static idx_t NestedSelectOperation(Vector &left, Vector &right, const SelectionV
|
|
|
48450
48407
|
count = match_count;
|
|
48451
48408
|
|
|
48452
48409
|
// Now that we have handled the NULLs, we can use the recursive nested comparator for the rest.
|
|
48453
|
-
match_count = NestedSelector::Select<OP>(l_not_null, r_not_null,
|
|
48410
|
+
match_count = NestedSelector::Select<OP>(l_not_null, r_not_null, maybe_vec, count, true_opt, false_opt);
|
|
48454
48411
|
no_match_count += (count - match_count);
|
|
48455
48412
|
|
|
48456
48413
|
// Copy the buffered selections to the output selections
|
|
@@ -78643,6 +78600,9 @@ void HistogramFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
78643
78600
|
fun.AddFunction(GetHistogramFunction(PhysicalType::VARCHAR));
|
|
78644
78601
|
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP));
|
|
78645
78602
|
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP_TZ));
|
|
78603
|
+
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP_S));
|
|
78604
|
+
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP_MS));
|
|
78605
|
+
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP_NS));
|
|
78646
78606
|
set.AddFunction(fun);
|
|
78647
78607
|
}
|
|
78648
78608
|
|
|
@@ -153811,6 +153771,8 @@ public:
|
|
|
153811
153771
|
return max_count;
|
|
153812
153772
|
}
|
|
153813
153773
|
|
|
153774
|
+
unique_ptr<Expression> CreateExtraReference(unique_ptr<ParsedExpression> expr);
|
|
153775
|
+
|
|
153814
153776
|
private:
|
|
153815
153777
|
unique_ptr<Expression> CreateProjectionReference(ParsedExpression &expr, idx_t index);
|
|
153816
153778
|
|
|
@@ -153844,9 +153806,13 @@ unique_ptr<Expression> Binder::BindOrderExpression(OrderBinder &order_binder, un
|
|
|
153844
153806
|
return bound_expr;
|
|
153845
153807
|
}
|
|
153846
153808
|
|
|
153847
|
-
unique_ptr<Expression> Binder::BindDelimiter(ClientContext &context,
|
|
153848
|
-
const LogicalType &type,
|
|
153809
|
+
unique_ptr<Expression> Binder::BindDelimiter(ClientContext &context, OrderBinder &order_binder,
|
|
153810
|
+
unique_ptr<ParsedExpression> delimiter, const LogicalType &type,
|
|
153811
|
+
Value &delimiter_value) {
|
|
153849
153812
|
auto new_binder = Binder::CreateBinder(context, this, true);
|
|
153813
|
+
if (delimiter->HasSubquery()) {
|
|
153814
|
+
return order_binder.CreateExtraReference(move(delimiter));
|
|
153815
|
+
}
|
|
153850
153816
|
ExpressionBinder expr_binder(*new_binder, context);
|
|
153851
153817
|
expr_binder.target_type = type;
|
|
153852
153818
|
auto expr = expr_binder.Bind(delimiter);
|
|
@@ -153858,11 +153824,11 @@ unique_ptr<Expression> Binder::BindDelimiter(ClientContext &context, unique_ptr<
|
|
|
153858
153824
|
return expr;
|
|
153859
153825
|
}
|
|
153860
153826
|
|
|
153861
|
-
unique_ptr<BoundResultModifier> Binder::BindLimit(LimitModifier &limit_mod) {
|
|
153827
|
+
unique_ptr<BoundResultModifier> Binder::BindLimit(OrderBinder &order_binder, LimitModifier &limit_mod) {
|
|
153862
153828
|
auto result = make_unique<BoundLimitModifier>();
|
|
153863
153829
|
if (limit_mod.limit) {
|
|
153864
153830
|
Value val;
|
|
153865
|
-
result->limit = BindDelimiter(context, move(limit_mod.limit), LogicalType::BIGINT, val);
|
|
153831
|
+
result->limit = BindDelimiter(context, order_binder, move(limit_mod.limit), LogicalType::BIGINT, val);
|
|
153866
153832
|
if (!result->limit) {
|
|
153867
153833
|
result->limit_val = val.GetValue<int64_t>();
|
|
153868
153834
|
if (result->limit_val < 0) {
|
|
@@ -153872,7 +153838,7 @@ unique_ptr<BoundResultModifier> Binder::BindLimit(LimitModifier &limit_mod) {
|
|
|
153872
153838
|
}
|
|
153873
153839
|
if (limit_mod.offset) {
|
|
153874
153840
|
Value val;
|
|
153875
|
-
result->offset = BindDelimiter(context, move(limit_mod.offset), LogicalType::BIGINT, val);
|
|
153841
|
+
result->offset = BindDelimiter(context, order_binder, move(limit_mod.offset), LogicalType::BIGINT, val);
|
|
153876
153842
|
if (!result->offset) {
|
|
153877
153843
|
result->offset_val = val.GetValue<int64_t>();
|
|
153878
153844
|
if (result->offset_val < 0) {
|
|
@@ -153883,11 +153849,11 @@ unique_ptr<BoundResultModifier> Binder::BindLimit(LimitModifier &limit_mod) {
|
|
|
153883
153849
|
return move(result);
|
|
153884
153850
|
}
|
|
153885
153851
|
|
|
153886
|
-
unique_ptr<BoundResultModifier> Binder::BindLimitPercent(LimitPercentModifier &limit_mod) {
|
|
153852
|
+
unique_ptr<BoundResultModifier> Binder::BindLimitPercent(OrderBinder &order_binder, LimitPercentModifier &limit_mod) {
|
|
153887
153853
|
auto result = make_unique<BoundLimitPercentModifier>();
|
|
153888
153854
|
if (limit_mod.limit) {
|
|
153889
153855
|
Value val;
|
|
153890
|
-
result->limit = BindDelimiter(context, move(limit_mod.limit), LogicalType::DOUBLE, val);
|
|
153856
|
+
result->limit = BindDelimiter(context, order_binder, move(limit_mod.limit), LogicalType::DOUBLE, val);
|
|
153891
153857
|
if (!result->limit) {
|
|
153892
153858
|
result->limit_percent = val.GetValue<double>();
|
|
153893
153859
|
if (result->limit_percent < 0.0) {
|
|
@@ -153897,7 +153863,7 @@ unique_ptr<BoundResultModifier> Binder::BindLimitPercent(LimitPercentModifier &l
|
|
|
153897
153863
|
}
|
|
153898
153864
|
if (limit_mod.offset) {
|
|
153899
153865
|
Value val;
|
|
153900
|
-
result->offset = BindDelimiter(context, move(limit_mod.offset), LogicalType::BIGINT, val);
|
|
153866
|
+
result->offset = BindDelimiter(context, order_binder, move(limit_mod.offset), LogicalType::BIGINT, val);
|
|
153901
153867
|
if (!result->offset) {
|
|
153902
153868
|
result->offset_val = val.GetValue<int64_t>();
|
|
153903
153869
|
}
|
|
@@ -153962,10 +153928,10 @@ void Binder::BindModifiers(OrderBinder &order_binder, QueryNode &statement, Boun
|
|
|
153962
153928
|
break;
|
|
153963
153929
|
}
|
|
153964
153930
|
case ResultModifierType::LIMIT_MODIFIER:
|
|
153965
|
-
bound_modifier = BindLimit((LimitModifier &)*mod);
|
|
153931
|
+
bound_modifier = BindLimit(order_binder, (LimitModifier &)*mod);
|
|
153966
153932
|
break;
|
|
153967
153933
|
case ResultModifierType::LIMIT_PERCENT_MODIFIER:
|
|
153968
|
-
bound_modifier = BindLimitPercent((LimitPercentModifier &)*mod);
|
|
153934
|
+
bound_modifier = BindLimitPercent(order_binder, (LimitPercentModifier &)*mod);
|
|
153969
153935
|
break;
|
|
153970
153936
|
default:
|
|
153971
153937
|
throw Exception("Unsupported result modifier");
|
|
@@ -153976,6 +153942,18 @@ void Binder::BindModifiers(OrderBinder &order_binder, QueryNode &statement, Boun
|
|
|
153976
153942
|
}
|
|
153977
153943
|
}
|
|
153978
153944
|
|
|
153945
|
+
static void AssignReturnType(unique_ptr<Expression> &expr, const vector<LogicalType> &sql_types,
|
|
153946
|
+
idx_t projection_index) {
|
|
153947
|
+
if (!expr) {
|
|
153948
|
+
return;
|
|
153949
|
+
}
|
|
153950
|
+
if (expr->type != ExpressionType::BOUND_COLUMN_REF) {
|
|
153951
|
+
return;
|
|
153952
|
+
}
|
|
153953
|
+
auto &bound_colref = (BoundColumnRefExpression &)*expr;
|
|
153954
|
+
bound_colref.return_type = sql_types[bound_colref.binding.column_index];
|
|
153955
|
+
}
|
|
153956
|
+
|
|
153979
153957
|
void Binder::BindModifierTypes(BoundQueryNode &result, const vector<LogicalType> &sql_types, idx_t projection_index) {
|
|
153980
153958
|
for (auto &bound_mod : result.modifiers) {
|
|
153981
153959
|
switch (bound_mod->type) {
|
|
@@ -154009,6 +153987,18 @@ void Binder::BindModifierTypes(BoundQueryNode &result, const vector<LogicalType>
|
|
|
154009
153987
|
}
|
|
154010
153988
|
break;
|
|
154011
153989
|
}
|
|
153990
|
+
case ResultModifierType::LIMIT_MODIFIER: {
|
|
153991
|
+
auto &limit = (BoundLimitModifier &)*bound_mod;
|
|
153992
|
+
AssignReturnType(limit.limit, sql_types, projection_index);
|
|
153993
|
+
AssignReturnType(limit.offset, sql_types, projection_index);
|
|
153994
|
+
break;
|
|
153995
|
+
}
|
|
153996
|
+
case ResultModifierType::LIMIT_PERCENT_MODIFIER: {
|
|
153997
|
+
auto &limit = (BoundLimitPercentModifier &)*bound_mod;
|
|
153998
|
+
AssignReturnType(limit.limit, sql_types, projection_index);
|
|
153999
|
+
AssignReturnType(limit.offset, sql_types, projection_index);
|
|
154000
|
+
break;
|
|
154001
|
+
}
|
|
154012
154002
|
case ResultModifierType::ORDER_MODIFIER: {
|
|
154013
154003
|
auto &order = (BoundOrderModifier &)*bound_mod;
|
|
154014
154004
|
for (auto &order_node : order.orders) {
|
|
@@ -154637,36 +154627,6 @@ unique_ptr<LogicalOperator> Binder::CreatePlan(BoundSelectNode &statement) {
|
|
|
154637
154627
|
PlanSubqueries(&expr, &root);
|
|
154638
154628
|
}
|
|
154639
154629
|
|
|
154640
|
-
for (size_t i = 0; i < statement.modifiers.size(); i++) {
|
|
154641
|
-
auto &modifier = statement.modifiers[i];
|
|
154642
|
-
unique_ptr<LogicalOperator> limit = nullptr;
|
|
154643
|
-
if (modifier->type == ResultModifierType::LIMIT_MODIFIER) {
|
|
154644
|
-
auto &limit_modifier = (BoundLimitModifier &)*modifier;
|
|
154645
|
-
if (limit_modifier.limit || limit_modifier.offset) {
|
|
154646
|
-
PlanSubqueries(&limit_modifier.limit, &root);
|
|
154647
|
-
PlanSubqueries(&limit_modifier.offset, &root);
|
|
154648
|
-
limit = make_unique<LogicalLimit>(limit_modifier.limit_val, limit_modifier.offset_val,
|
|
154649
|
-
move(limit_modifier.limit), move(limit_modifier.offset));
|
|
154650
|
-
}
|
|
154651
|
-
} else if (modifier->type == ResultModifierType::LIMIT_PERCENT_MODIFIER) {
|
|
154652
|
-
auto &limit_modifier = (BoundLimitPercentModifier &)*modifier;
|
|
154653
|
-
if (limit_modifier.limit || limit_modifier.offset) {
|
|
154654
|
-
PlanSubqueries(&limit_modifier.limit, &root);
|
|
154655
|
-
PlanSubqueries(&limit_modifier.offset, &root);
|
|
154656
|
-
limit = make_unique<LogicalLimitPercent>(limit_modifier.limit_percent, limit_modifier.offset_val,
|
|
154657
|
-
move(limit_modifier.limit), move(limit_modifier.offset));
|
|
154658
|
-
}
|
|
154659
|
-
}
|
|
154660
|
-
if (limit) {
|
|
154661
|
-
limit->AddChild(move(root));
|
|
154662
|
-
root = move(limit);
|
|
154663
|
-
// Delete from modifiers
|
|
154664
|
-
std::swap(statement.modifiers[i], statement.modifiers.back());
|
|
154665
|
-
statement.modifiers.erase(statement.modifiers.end() - 1);
|
|
154666
|
-
i--;
|
|
154667
|
-
}
|
|
154668
|
-
}
|
|
154669
|
-
|
|
154670
154630
|
// create the projection
|
|
154671
154631
|
auto proj = make_unique<LogicalProjection>(statement.projection_index, move(statement.select_list));
|
|
154672
154632
|
auto &projection = *proj;
|
|
@@ -160241,6 +160201,12 @@ unique_ptr<Expression> OrderBinder::CreateProjectionReference(ParsedExpression &
|
|
|
160241
160201
|
ColumnBinding(projection_index, index));
|
|
160242
160202
|
}
|
|
160243
160203
|
|
|
160204
|
+
unique_ptr<Expression> OrderBinder::CreateExtraReference(unique_ptr<ParsedExpression> expr) {
|
|
160205
|
+
auto result = CreateProjectionReference(*expr, extra_list->size());
|
|
160206
|
+
extra_list->push_back(move(expr));
|
|
160207
|
+
return result;
|
|
160208
|
+
}
|
|
160209
|
+
|
|
160244
160210
|
unique_ptr<Expression> OrderBinder::Bind(unique_ptr<ParsedExpression> expr) {
|
|
160245
160211
|
// in the ORDER BY clause we do not bind children
|
|
160246
160212
|
// we bind ONLY to the select list
|
|
@@ -160311,9 +160277,7 @@ unique_ptr<Expression> OrderBinder::Bind(unique_ptr<ParsedExpression> expr) {
|
|
|
160311
160277
|
expr->ToString());
|
|
160312
160278
|
}
|
|
160313
160279
|
// otherwise we need to push the ORDER BY entry into the select list
|
|
160314
|
-
|
|
160315
|
-
extra_list->push_back(move(expr));
|
|
160316
|
-
return result;
|
|
160280
|
+
return CreateExtraReference(move(expr));
|
|
160317
160281
|
}
|
|
160318
160282
|
|
|
160319
160283
|
} // namespace duckdb
|