duckdb 1.1.4-dev2.0 → 1.1.4-dev9.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/.github/workflows/NodeJS.yml +5 -54
- package/binding.gyp +73 -52
- package/package.json +1 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/algebraic/avg.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/algebraic/corr.cpp +4 -4
- package/src/duckdb/{src → extension}/core_functions/aggregate/algebraic/covar.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/algebraic/stddev.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/approx_count.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/arg_min_max.cpp +66 -18
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/bitagg.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/bitstring_agg.cpp +5 -7
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/bool.cpp +3 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/kurtosis.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/product.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/skew.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/string_agg.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/distributive/sum.cpp +13 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/holistic/approx_top_k.cpp +3 -3
- package/src/duckdb/{src → extension}/core_functions/aggregate/holistic/approximate_quantile.cpp +51 -15
- package/src/duckdb/{src → extension}/core_functions/aggregate/holistic/mad.cpp +25 -10
- package/src/duckdb/{src → extension}/core_functions/aggregate/holistic/mode.cpp +215 -71
- package/src/duckdb/{src → extension}/core_functions/aggregate/holistic/quantile.cpp +58 -31
- package/src/duckdb/{src → extension}/core_functions/aggregate/holistic/reservoir_quantile.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/nested/binned_histogram.cpp +9 -4
- package/src/duckdb/{src → extension}/core_functions/aggregate/nested/histogram.cpp +4 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/nested/list.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/regression/regr_avg.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/aggregate/regression/regr_count.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/regression/regr_intercept.cpp +6 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/regression/regr_r2.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/regression/regr_slope.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/regression/regr_sxx_syy.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/aggregate/regression/regr_sxy.cpp +3 -3
- package/src/duckdb/extension/core_functions/core_functions_extension.cpp +85 -0
- package/src/duckdb/{src → extension}/core_functions/function_list.cpp +30 -51
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/algebraic/corr.hpp +3 -7
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/algebraic_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/distributive_functions.hpp +16 -21
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/histogram_helpers.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/holistic_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/nested_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/quantile_helpers.hpp +2 -2
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/quantile_sort_tree.hpp +140 -58
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/quantile_state.hpp +50 -43
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/regression/regr_count.hpp +2 -2
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/regression/regr_slope.hpp +3 -7
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/regression_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/array_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/bit_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/blob_functions.hpp +1 -10
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/date_functions.hpp +22 -55
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/debug_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/enum_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/generic_functions.hpp +1 -10
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/list_functions.hpp +4 -4
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/map_functions.hpp +1 -10
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/math_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/operators_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/random_functions.hpp +1 -1
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/string_functions.hpp +10 -103
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/struct_functions.hpp +1 -19
- package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/union_functions.hpp +1 -1
- package/src/duckdb/extension/core_functions/include/core_functions_extension.hpp +22 -0
- package/src/duckdb/{src → extension}/core_functions/lambda_functions.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/array/array_functions.cpp +11 -4
- package/src/duckdb/{src → extension}/core_functions/scalar/array/array_value.cpp +2 -2
- package/src/duckdb/{src → extension}/core_functions/scalar/bit/bitstring.cpp +12 -5
- package/src/duckdb/{src → extension}/core_functions/scalar/blob/base64.cpp +4 -2
- package/src/duckdb/{src → extension}/core_functions/scalar/blob/encode.cpp +4 -2
- package/src/duckdb/{src → extension}/core_functions/scalar/date/age.cpp +9 -3
- package/src/duckdb/extension/core_functions/scalar/date/current.cpp +29 -0
- package/src/duckdb/{src → extension}/core_functions/scalar/date/date_diff.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/date/date_part.cpp +42 -9
- package/src/duckdb/{src → extension}/core_functions/scalar/date/date_sub.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/date/date_trunc.cpp +4 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/date/epoch.cpp +19 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/date/make_date.cpp +40 -5
- package/src/duckdb/{src → extension}/core_functions/scalar/date/time_bucket.cpp +4 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/date/to_interval.cpp +54 -28
- package/src/duckdb/{src → extension}/core_functions/scalar/debug/vector_type.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/enum/enum_functions.cpp +2 -7
- package/src/duckdb/{src → extension}/core_functions/scalar/generic/alias.cpp +2 -2
- package/src/duckdb/{src/function → extension/core_functions}/scalar/generic/binning.cpp +4 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/generic/can_implicitly_cast.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/generic/current_setting.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/generic/hash.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/generic/least.cpp +30 -10
- package/src/duckdb/{src → extension}/core_functions/scalar/generic/stats.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/generic/system_functions.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/generic/typeof.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/list/array_slice.cpp +93 -88
- package/src/duckdb/{src → extension}/core_functions/scalar/list/flatten.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/list/list_aggregates.cpp +7 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/list/list_distance.cpp +8 -2
- package/src/duckdb/{src → extension}/core_functions/scalar/list/list_filter.cpp +3 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/list/list_has_any_or_all.cpp +3 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/list/list_reduce.cpp +5 -5
- package/src/duckdb/{src → extension}/core_functions/scalar/list/list_sort.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/list/list_transform.cpp +3 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/list/list_value.cpp +3 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/list/range.cpp +7 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/map/cardinality.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/map/map.cpp +5 -4
- package/src/duckdb/{src → extension}/core_functions/scalar/map/map_concat.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/map/map_entries.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/map/map_extract.cpp +13 -25
- package/src/duckdb/{src → extension}/core_functions/scalar/map/map_from_entries.cpp +2 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/map/map_keys_values.cpp +11 -9
- package/src/duckdb/{src → extension}/core_functions/scalar/math/numeric.cpp +83 -37
- package/src/duckdb/{src → extension}/core_functions/scalar/operators/bitwise.cpp +19 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/random/random.cpp +4 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/random/setseed.cpp +2 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/ascii.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/bar.cpp +6 -4
- package/src/duckdb/{src → extension}/core_functions/scalar/string/chr.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/damerau_levenshtein.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/format_bytes.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/hamming.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/hex.cpp +7 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/string/instr.cpp +4 -4
- package/src/duckdb/{src → extension}/core_functions/scalar/string/jaccard.cpp +1 -1
- package/src/duckdb/extension/core_functions/scalar/string/jaro_winkler.cpp +112 -0
- package/src/duckdb/{src → extension}/core_functions/scalar/string/left_right.cpp +6 -6
- package/src/duckdb/{src → extension}/core_functions/scalar/string/levenshtein.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/pad.cpp +9 -5
- package/src/duckdb/{src → extension}/core_functions/scalar/string/parse_path.cpp +4 -4
- package/src/duckdb/{src → extension}/core_functions/scalar/string/printf.cpp +3 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/repeat.cpp +4 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/replace.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/reverse.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/starts_with.cpp +5 -3
- package/src/duckdb/{src → extension}/core_functions/scalar/string/to_base.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/translate.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/trim.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/unicode.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/string/url_encode.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/struct/struct_insert.cpp +25 -31
- package/src/duckdb/{src → extension}/core_functions/scalar/union/union_extract.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/union/union_tag.cpp +1 -1
- package/src/duckdb/{src → extension}/core_functions/scalar/union/union_value.cpp +3 -3
- package/src/duckdb/extension/icu/icu-dateadd.cpp +16 -11
- package/src/duckdb/extension/icu/icu-datefunc.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datepart.cpp +8 -5
- package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +8 -1
- package/src/duckdb/extension/icu/icu-list-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-makedate.cpp +18 -7
- package/src/duckdb/extension/icu/icu-strptime.cpp +9 -3
- package/src/duckdb/extension/icu/icu-table-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-timebucket.cpp +4 -1
- package/src/duckdb/extension/icu/icu-timezone.cpp +67 -1
- package/src/duckdb/extension/icu/icu_extension.cpp +60 -5
- package/src/duckdb/extension/icu/include/icu-datefunc.hpp +2 -1
- package/src/duckdb/extension/icu/third_party/icu/common/bytestriebuilder.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/dtintrv.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/filteredbrk.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/locid.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/lsr.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/lsr.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/common/messagepattern.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/common/normlzr.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/rbbinode.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/schriter.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/stringtriebuilder.cpp +8 -8
- package/src/duckdb/extension/icu/third_party/icu/common/ucharstriebuilder.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/uchriter.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/brkiter.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/bytestriebuilder.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/chariter.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/dtintrv.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/locid.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/messagepattern.h +4 -4
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/normlzr.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/parsepos.h +4 -4
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/rbbi.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/schriter.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/strenum.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/stringpiece.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/stringtriebuilder.h +9 -9
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/ucharstriebuilder.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/uchriter.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/uniset.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/unistr.h +12 -12
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/uobject.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/common/unifiedcache.h +4 -4
- package/src/duckdb/extension/icu/third_party/icu/common/uniset.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/ustr_titlecase_brkiter.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/ustrenum.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/common/uvector.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/uvector.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/common/uvectr32.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/uvectr32.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/common/uvectr64.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/common/uvectr64.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/i18n/alphaindex.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/calendar.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/choicfmt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/coleitr.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/coll.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/collationiterator.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/collationiterator.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/collationsettings.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/collationsettings.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/currpinf.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/datefmt.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/dcfmtsym.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/decimfmt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/dtfmtsym.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/dtitvfmt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/dtitvinf.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/dtptngen.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/dtptngen_impl.h +4 -4
- package/src/duckdb/extension/icu/third_party/icu/i18n/dtrule.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/fmtable.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/format.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/fpositer.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/measfmt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/measunit.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/measure.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/msgfmt.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/nfrs.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/nfrs.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/nfrule.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/nfrule.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/nfsubs.cpp +9 -9
- package/src/duckdb/extension/icu/third_party/icu/i18n/nfsubs.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/number_asformat.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/number_asformat.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/numfmt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/olsontz.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/olsontz.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/plurfmt.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/plurrule.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/rbnf.cpp +4 -4
- package/src/duckdb/extension/icu/third_party/icu/i18n/rbtz.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/region.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/reldtfmt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/reldtfmt.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/rulebasedcollator.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/selfmt.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/simpletz.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/smpdtfmt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/sortkey.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/timezone.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/tmutamt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/tzfmt.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/tzgnames.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/tzgnames.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/tznames.cpp +3 -3
- package/src/duckdb/extension/icu/third_party/icu/i18n/tznames_impl.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/tznames_impl.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/tzrule.cpp +8 -8
- package/src/duckdb/extension/icu/third_party/icu/i18n/tztrans.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/alphaindex.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/calendar.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/choicfmt.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/coleitr.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/coll.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/currpinf.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/datefmt.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/dcfmtsym.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/decimfmt.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/dtfmtsym.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/dtitvfmt.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/dtitvinf.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/dtptngen.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/dtrule.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/fieldpos.h +4 -4
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/fmtable.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/format.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/fpositer.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/measfmt.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/measunit.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/measure.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/msgfmt.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/numfmt.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/plurfmt.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/plurrule.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/rbnf.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/rbtz.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/region.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/search.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/selfmt.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/simpletz.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/smpdtfmt.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/sortkey.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/stsearch.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/tblcoll.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/timezone.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/tmutamt.h +3 -3
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/tmutfmt.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/tzfmt.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/tznames.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/tzrule.h +8 -8
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/tztrans.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/vtzone.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/utf16collationiterator.cpp +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/utf16collationiterator.h +2 -2
- package/src/duckdb/extension/icu/third_party/icu/i18n/vtzone.cpp +2 -2
- package/src/duckdb/extension/json/buffered_json_reader.cpp +6 -1
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +2 -0
- package/src/duckdb/extension/json/include/json_common.hpp +14 -10
- package/src/duckdb/extension/json/include/json_scan.hpp +48 -7
- package/src/duckdb/extension/json/include/json_structure.hpp +2 -1
- package/src/duckdb/extension/json/include/json_transform.hpp +5 -2
- package/src/duckdb/extension/json/json_functions/copy_json.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_create.cpp +57 -20
- package/src/duckdb/extension/json/json_functions/json_serialize_plan.cpp +7 -6
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +6 -5
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +20 -17
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +48 -17
- package/src/duckdb/extension/json/json_functions/read_json.cpp +83 -34
- package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +3 -3
- package/src/duckdb/extension/json/json_functions.cpp +14 -16
- package/src/duckdb/extension/json/json_scan.cpp +36 -16
- package/src/duckdb/extension/json/json_serializer.cpp +1 -1
- package/src/duckdb/extension/json/serialize_json.cpp +2 -2
- package/src/duckdb/extension/parquet/column_reader.cpp +136 -116
- package/src/duckdb/extension/parquet/column_writer.cpp +870 -604
- package/src/duckdb/extension/parquet/geo_parquet.cpp +4 -5
- package/src/duckdb/extension/parquet/include/boolean_column_reader.hpp +0 -4
- package/src/duckdb/extension/parquet/include/column_reader.hpp +24 -19
- package/src/duckdb/extension/parquet/include/column_writer.hpp +7 -5
- package/src/duckdb/extension/parquet/include/decode_utils.hpp +138 -18
- package/src/duckdb/extension/parquet/include/geo_parquet.hpp +4 -3
- package/src/duckdb/extension/parquet/include/null_column_reader.hpp +1 -14
- package/src/duckdb/extension/parquet/include/parquet_bss_encoder.hpp +45 -0
- package/src/duckdb/extension/parquet/include/parquet_crypto.hpp +1 -1
- package/src/duckdb/extension/parquet/include/parquet_dbp_decoder.hpp +101 -90
- package/src/duckdb/extension/parquet/include/parquet_dbp_encoder.hpp +179 -0
- package/src/duckdb/extension/parquet/include/parquet_decimal_utils.hpp +2 -3
- package/src/duckdb/extension/parquet/include/parquet_dlba_encoder.hpp +48 -0
- package/src/duckdb/extension/parquet/include/parquet_extension.hpp +8 -0
- package/src/duckdb/extension/parquet/include/parquet_file_metadata_cache.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_metadata.hpp +5 -0
- package/src/duckdb/extension/parquet/include/parquet_reader.hpp +22 -18
- package/src/duckdb/extension/parquet/include/parquet_rle_bp_decoder.hpp +1 -5
- package/src/duckdb/extension/parquet/include/parquet_statistics.hpp +87 -3
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +30 -16
- package/src/duckdb/extension/parquet/include/resizable_buffer.hpp +1 -0
- package/src/duckdb/extension/parquet/include/string_column_reader.hpp +0 -8
- package/src/duckdb/extension/parquet/include/struct_column_reader.hpp +1 -1
- package/src/duckdb/extension/parquet/include/templated_column_reader.hpp +1 -42
- package/src/duckdb/extension/parquet/include/thrift_tools.hpp +13 -1
- package/src/duckdb/extension/parquet/include/zstd_file_system.hpp +4 -0
- package/src/duckdb/extension/parquet/parquet_extension.cpp +240 -197
- package/src/duckdb/extension/parquet/parquet_metadata.cpp +138 -6
- package/src/duckdb/extension/parquet/parquet_reader.cpp +155 -79
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +258 -38
- package/src/duckdb/extension/parquet/parquet_timestamp.cpp +17 -3
- package/src/duckdb/extension/parquet/parquet_writer.cpp +65 -34
- package/src/duckdb/extension/parquet/serialize_parquet.cpp +4 -0
- package/src/duckdb/extension/parquet/zstd_file_system.cpp +13 -0
- package/src/duckdb/src/catalog/catalog.cpp +272 -97
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +9 -4
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +8 -0
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +145 -95
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +9 -3
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +15 -0
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +40 -24
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry.cpp +3 -0
- package/src/duckdb/src/catalog/catalog_entry_retriever.cpp +60 -5
- package/src/duckdb/src/catalog/catalog_search_path.cpp +27 -14
- package/src/duckdb/src/catalog/catalog_set.cpp +75 -31
- package/src/duckdb/src/catalog/default/default_functions.cpp +13 -8
- package/src/duckdb/src/catalog/default/default_views.cpp +1 -0
- package/src/duckdb/src/catalog/dependency_manager.cpp +133 -5
- package/src/duckdb/src/catalog/duck_catalog.cpp +17 -9
- package/src/duckdb/src/common/adbc/adbc.cpp +18 -0
- package/src/duckdb/src/common/allocator.cpp +3 -1
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +30 -9
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +63 -82
- package/src/duckdb/src/common/arrow/arrow_merge_event.cpp +4 -3
- package/src/duckdb/src/common/arrow/arrow_type_extension.cpp +361 -0
- package/src/duckdb/src/common/arrow/arrow_util.cpp +10 -6
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +6 -2
- package/src/duckdb/src/common/arrow/physical_arrow_collector.cpp +2 -1
- package/src/duckdb/src/common/arrow/schema_metadata.cpp +27 -14
- package/src/duckdb/src/common/assert.cpp +1 -2
- package/src/duckdb/src/common/bind_helpers.cpp +1 -1
- package/src/duckdb/src/common/box_renderer.cpp +316 -26
- package/src/duckdb/src/common/cgroups.cpp +7 -1
- package/src/duckdb/src/common/compressed_file_system.cpp +1 -1
- package/src/duckdb/src/common/enum_util.cpp +2865 -6882
- package/src/duckdb/src/common/enums/compression_type.cpp +12 -0
- package/src/duckdb/src/common/enums/metric_type.cpp +24 -0
- package/src/duckdb/src/common/enums/optimizer_type.cpp +4 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/error_data.cpp +23 -6
- package/src/duckdb/src/common/exception/binder_exception.cpp +1 -1
- package/src/duckdb/src/common/exception.cpp +20 -28
- package/src/duckdb/src/common/extra_type_info.cpp +85 -20
- package/src/duckdb/src/common/file_buffer.cpp +5 -2
- package/src/duckdb/src/common/file_system.cpp +8 -3
- package/src/duckdb/src/common/fsst.cpp +3 -3
- package/src/duckdb/src/common/hive_partitioning.cpp +1 -1
- package/src/duckdb/src/common/local_file_system.cpp +169 -60
- package/src/duckdb/src/common/multi_file_list.cpp +4 -1
- package/src/duckdb/src/common/multi_file_reader.cpp +240 -63
- package/src/duckdb/src/common/opener_file_system.cpp +37 -0
- package/src/duckdb/src/common/operator/cast_operators.cpp +77 -11
- package/src/duckdb/src/common/operator/string_cast.cpp +6 -2
- package/src/duckdb/src/common/pipe_file_system.cpp +4 -4
- package/src/duckdb/src/common/progress_bar/progress_bar.cpp +25 -14
- package/src/duckdb/src/common/radix_partitioning.cpp +17 -16
- package/src/duckdb/src/common/random_engine.cpp +39 -3
- package/src/duckdb/src/common/render_tree.cpp +3 -19
- package/src/duckdb/src/common/row_operations/row_external.cpp +1 -1
- package/src/duckdb/src/common/row_operations/row_gather.cpp +2 -58
- package/src/duckdb/src/common/row_operations/row_matcher.cpp +2 -2
- package/src/duckdb/src/common/row_operations/row_radix_scatter.cpp +2 -0
- package/src/duckdb/src/common/row_operations/row_scatter.cpp +20 -19
- package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +1 -1
- package/src/duckdb/src/common/serializer/memory_stream.cpp +36 -0
- package/src/duckdb/src/common/sort/comparators.cpp +7 -7
- package/src/duckdb/src/common/sort/partition_state.cpp +2 -2
- package/src/duckdb/src/common/stacktrace.cpp +127 -0
- package/src/duckdb/src/common/string_util.cpp +157 -32
- package/src/duckdb/src/common/tree_renderer/text_tree_renderer.cpp +15 -3
- package/src/duckdb/src/common/types/column/column_data_allocator.cpp +4 -0
- package/src/duckdb/src/common/types/column/column_data_collection.cpp +71 -8
- package/src/duckdb/src/common/types/column/column_data_collection_segment.cpp +27 -6
- package/src/duckdb/src/common/types/conflict_manager.cpp +21 -7
- package/src/duckdb/src/common/types/date.cpp +39 -25
- package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +4 -11
- package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +21 -7
- package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +10 -1
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +17 -17
- package/src/duckdb/src/common/types/timestamp.cpp +70 -33
- package/src/duckdb/src/common/types/uuid.cpp +11 -0
- package/src/duckdb/src/common/types/validity_mask.cpp +16 -5
- package/src/duckdb/src/common/types/value.cpp +357 -199
- package/src/duckdb/src/common/types/varint.cpp +64 -18
- package/src/duckdb/src/common/types/vector.cpp +78 -38
- package/src/duckdb/src/common/types.cpp +199 -92
- package/src/duckdb/src/common/vector_operations/comparison_operators.cpp +2 -1
- package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +32 -5
- package/src/duckdb/src/common/vector_operations/vector_hash.cpp +3 -1
- package/src/duckdb/src/execution/adaptive_filter.cpp +6 -2
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +410 -111
- package/src/duckdb/src/execution/column_binding_resolver.cpp +2 -2
- package/src/duckdb/src/execution/expression_executor/execute_between.cpp +6 -0
- package/src/duckdb/src/execution/expression_executor/execute_cast.cpp +4 -3
- package/src/duckdb/src/execution/expression_executor/execute_comparison.cpp +2 -2
- package/src/duckdb/src/execution/expression_executor/execute_conjunction.cpp +2 -2
- package/src/duckdb/src/execution/expression_executor/execute_function.cpp +1 -0
- package/src/duckdb/src/execution/expression_executor/execute_operator.cpp +5 -4
- package/src/duckdb/src/execution/expression_executor.cpp +5 -3
- package/src/duckdb/src/execution/index/art/art.cpp +208 -72
- package/src/duckdb/src/execution/index/art/base_leaf.cpp +1 -1
- package/src/duckdb/src/execution/index/art/leaf.cpp +12 -7
- package/src/duckdb/src/execution/index/art/node.cpp +2 -1
- package/src/duckdb/src/execution/index/art/node256_leaf.cpp +6 -6
- package/src/duckdb/src/execution/index/art/plan_art.cpp +50 -55
- package/src/duckdb/src/execution/index/art/prefix.cpp +7 -13
- package/src/duckdb/src/execution/index/bound_index.cpp +30 -5
- package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +3 -5
- package/src/duckdb/src/execution/index/fixed_size_buffer.cpp +14 -9
- package/src/duckdb/src/execution/join_hashtable.cpp +254 -158
- package/src/duckdb/src/execution/operator/aggregate/grouped_aggregate_data.cpp +1 -1
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +7 -7
- package/src/duckdb/src/execution/operator/aggregate/physical_partitioned_aggregate.cpp +226 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +3 -3
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +3 -3
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +77 -70
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +114 -50
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer.cpp +2 -2
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer_manager.cpp +19 -10
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_file_handle.cpp +22 -15
- package/src/duckdb/src/execution/operator/csv_scanner/encode/csv_encoder.cpp +95 -0
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/column_count_scanner.cpp +6 -1
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/csv_schema.cpp +75 -2
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/scanner_boundary.cpp +40 -12
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +395 -163
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +20 -23
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +115 -49
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/header_detection.cpp +66 -12
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +20 -23
- package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.cpp +220 -46
- package/src/duckdb/src/execution/operator/csv_scanner/table_function/csv_file_scanner.cpp +43 -32
- package/src/duckdb/src/execution/operator/csv_scanner/table_function/global_csv_state.cpp +54 -119
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_error.cpp +184 -20
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_reader_options.cpp +83 -21
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_validator.cpp +63 -0
- package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +7 -4
- package/src/duckdb/src/execution/operator/helper/physical_set.cpp +1 -1
- package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +3 -2
- package/src/duckdb/src/execution/operator/helper/physical_verify_vector.cpp +9 -1
- package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +132 -15
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +64 -55
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +284 -154
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +40 -55
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +0 -1
- package/src/duckdb/src/execution/operator/order/physical_order.cpp +7 -3
- package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +298 -227
- package/src/duckdb/src/execution/operator/persistent/csv_rejects_table.cpp +5 -2
- package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +3 -4
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +32 -19
- package/src/duckdb/src/execution/operator/persistent/physical_copy_database.cpp +1 -0
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +6 -0
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +58 -19
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +11 -27
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +308 -119
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +105 -55
- package/src/duckdb/src/execution/operator/projection/physical_tableinout_function.cpp +6 -2
- package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +1 -1
- package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +15 -6
- package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +92 -50
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +0 -1
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +8 -4
- package/src/duckdb/src/execution/operator/schema/physical_create_art_index.cpp +54 -22
- package/src/duckdb/src/execution/operator/set/physical_union.cpp +5 -1
- package/src/duckdb/src/execution/physical_operator.cpp +15 -9
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +101 -12
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +11 -140
- package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +11 -13
- package/src/duckdb/src/execution/physical_plan/plan_cte.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_distinct.cpp +6 -5
- package/src/duckdb/src/execution/physical_plan/plan_export.cpp +0 -4
- package/src/duckdb/src/execution/physical_plan/plan_filter.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_get.cpp +16 -13
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_order.cpp +7 -7
- package/src/duckdb/src/execution/physical_plan/plan_prepare.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_projection.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_sample.cpp +8 -3
- package/src/duckdb/src/execution/physical_plan/plan_set_operation.cpp +1 -2
- package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +1 -2
- package/src/duckdb/src/execution/physical_plan/plan_top_n.cpp +3 -2
- package/src/duckdb/src/execution/physical_plan_generator.cpp +0 -22
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +136 -116
- package/src/duckdb/src/execution/sample/base_reservoir_sample.cpp +136 -0
- package/src/duckdb/src/execution/sample/reservoir_sample.cpp +930 -0
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +6 -12
- package/src/duckdb/src/function/aggregate/distributive/{first.cpp → first_last_any.cpp} +37 -18
- package/src/duckdb/src/{core_functions → function}/aggregate/distributive/minmax.cpp +19 -12
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +72 -13
- package/src/duckdb/src/function/built_in_functions.cpp +85 -2
- package/src/duckdb/src/function/cast/decimal_cast.cpp +1 -1
- package/src/duckdb/src/function/cast/string_cast.cpp +1 -1
- package/src/duckdb/src/function/cast/struct_cast.cpp +81 -49
- package/src/duckdb/src/function/cast/union/from_struct.cpp +7 -5
- package/src/duckdb/src/function/compression_config.cpp +6 -0
- package/src/duckdb/src/function/encoding_function.cpp +134 -0
- package/src/duckdb/src/function/function.cpp +8 -13
- package/src/duckdb/src/function/function_binder.cpp +100 -21
- package/src/duckdb/src/function/function_list.cpp +178 -0
- package/src/duckdb/src/function/macro_function.cpp +4 -4
- package/src/duckdb/src/function/pragma/pragma_functions.cpp +0 -2
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +0 -4
- package/src/duckdb/src/{core_functions/core_functions.cpp → function/register_function_list.cpp} +12 -8
- package/src/duckdb/src/function/scalar/compressed_materialization/compress_integral.cpp +62 -23
- package/src/duckdb/src/function/scalar/compressed_materialization/compress_string.cpp +33 -16
- package/src/duckdb/src/function/scalar/compressed_materialization_utils.cpp +21 -0
- package/src/duckdb/src/{core_functions/scalar/blob → function/scalar}/create_sort_key.cpp +86 -23
- package/src/duckdb/src/{core_functions → function}/scalar/date/strftime.cpp +6 -4
- package/src/duckdb/src/function/scalar/generic/constant_or_null.cpp +5 -7
- package/src/duckdb/src/{core_functions → function}/scalar/generic/error.cpp +3 -1
- package/src/duckdb/src/function/scalar/generic/getvariable.cpp +2 -2
- package/src/duckdb/src/function/scalar/list/contains_or_position.cpp +1 -7
- package/src/duckdb/src/function/scalar/list/list_extract.cpp +27 -21
- package/src/duckdb/src/function/scalar/list/list_resize.cpp +8 -12
- package/src/duckdb/src/function/scalar/list/list_select.cpp +1 -4
- package/src/duckdb/src/function/scalar/list/list_zip.cpp +6 -6
- package/src/duckdb/src/{core_functions → function}/scalar/map/map_contains.cpp +2 -2
- package/src/duckdb/src/function/scalar/nested_functions.cpp +0 -11
- package/src/duckdb/src/function/scalar/{operators → operator}/add.cpp +2 -1
- package/src/duckdb/src/function/scalar/{operators → operator}/arithmetic.cpp +195 -127
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +30 -21
- package/src/duckdb/src/function/scalar/strftime_format.cpp +10 -0
- package/src/duckdb/src/function/scalar/string/caseconvert.cpp +11 -41
- package/src/duckdb/src/function/scalar/string/concat.cpp +22 -20
- package/src/duckdb/src/function/scalar/string/concat_ws.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/contains.cpp +16 -19
- package/src/duckdb/src/function/scalar/string/length.cpp +38 -24
- package/src/duckdb/src/function/scalar/string/like.cpp +80 -47
- package/src/duckdb/src/{core_functions → function}/scalar/string/md5.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/nfc_normalize.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/prefix.cpp +0 -4
- package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +2 -1
- package/src/duckdb/src/function/scalar/string/regexp.cpp +17 -7
- package/src/duckdb/src/{core_functions → function}/scalar/string/regexp_escape.cpp +2 -2
- package/src/duckdb/src/{core_functions → function}/scalar/string/sha1.cpp +1 -1
- package/src/duckdb/src/{core_functions → function}/scalar/string/sha256.cpp +1 -1
- package/src/duckdb/src/{core_functions → function}/scalar/string/string_split.cpp +4 -5
- package/src/duckdb/src/function/scalar/string/strip_accents.cpp +3 -6
- package/src/duckdb/src/function/scalar/string/substring.cpp +14 -13
- package/src/duckdb/src/function/scalar/string/suffix.cpp +0 -4
- package/src/duckdb/src/function/scalar/struct/struct_concat.cpp +115 -0
- package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +35 -31
- package/src/duckdb/src/{core_functions → function}/scalar/struct/struct_pack.cpp +7 -7
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -8
- package/src/duckdb/src/function/scalar/system/write_log.cpp +170 -0
- package/src/duckdb/src/function/scalar_function.cpp +5 -5
- package/src/duckdb/src/function/table/arrow/arrow_array_scan_state.cpp +3 -2
- package/src/duckdb/src/function/table/arrow/arrow_duck_schema.cpp +287 -1
- package/src/duckdb/src/function/table/arrow/arrow_type_info.cpp +6 -6
- package/src/duckdb/src/function/table/arrow.cpp +32 -352
- package/src/duckdb/src/function/table/arrow_conversion.cpp +43 -7
- package/src/duckdb/src/function/table/copy_csv.cpp +38 -23
- package/src/duckdb/src/function/table/glob.cpp +1 -1
- package/src/duckdb/src/function/table/query_function.cpp +12 -7
- package/src/duckdb/src/function/table/read_csv.cpp +114 -46
- package/src/duckdb/src/function/table/read_file.cpp +26 -6
- package/src/duckdb/src/function/table/sniff_csv.cpp +25 -5
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +6 -7
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +141 -16
- package/src/duckdb/src/function/table/system/duckdb_log.cpp +64 -0
- package/src/duckdb/src/function/table/system/duckdb_log_contexts.cpp +65 -0
- package/src/duckdb/src/function/table/system/duckdb_memory.cpp +0 -1
- package/src/duckdb/src/function/table/system/duckdb_settings.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +1 -13
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +17 -0
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +6 -0
- package/src/duckdb/src/function/table/system/pragma_table_sample.cpp +95 -0
- package/src/duckdb/src/function/table/system/test_all_types.cpp +56 -46
- package/src/duckdb/src/function/table/system_functions.cpp +3 -0
- package/src/duckdb/src/function/table/table_scan.cpp +487 -289
- package/src/duckdb/src/function/table/version/pragma_version.cpp +3 -3
- package/src/duckdb/src/function/table_function.cpp +10 -6
- package/src/duckdb/src/function/window/window_aggregate_function.cpp +248 -0
- package/src/duckdb/src/function/window/window_aggregate_states.cpp +48 -0
- package/src/duckdb/src/function/window/window_aggregator.cpp +88 -0
- package/src/duckdb/src/function/window/window_boundaries_state.cpp +854 -0
- package/src/duckdb/src/function/window/window_collection.cpp +146 -0
- package/src/duckdb/src/function/window/window_constant_aggregator.cpp +357 -0
- package/src/duckdb/src/function/window/window_custom_aggregator.cpp +146 -0
- package/src/duckdb/src/function/window/window_distinct_aggregator.cpp +758 -0
- package/src/duckdb/src/function/window/window_executor.cpp +99 -0
- package/src/duckdb/src/function/window/window_index_tree.cpp +63 -0
- package/src/duckdb/src/function/window/window_merge_sort_tree.cpp +275 -0
- package/src/duckdb/src/function/window/window_naive_aggregator.cpp +361 -0
- package/src/duckdb/src/function/window/window_rank_function.cpp +288 -0
- package/src/duckdb/src/function/window/window_rownumber_function.cpp +191 -0
- package/src/duckdb/src/function/window/window_segment_tree.cpp +594 -0
- package/src/duckdb/src/function/window/window_shared_expressions.cpp +50 -0
- package/src/duckdb/src/function/window/window_token_tree.cpp +142 -0
- package/src/duckdb/src/function/window/window_value_function.cpp +566 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +74 -17
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +9 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/function_entry.hpp +4 -10
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +18 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +5 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry_retriever.hpp +21 -18
- package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +3 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +10 -2
- package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +11 -0
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +9 -4
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/array_ptr.hpp +8 -0
- package/src/duckdb/src/include/duckdb/common/arrow/appender/append_data.hpp +4 -1
- package/src/duckdb/src/include/duckdb/common/arrow/appender/list_data.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/arrow/appender/list_view_data.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/arrow/appender/varchar_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +7 -3
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_converter.hpp +26 -3
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_query_result.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_type_extension.hpp +144 -0
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_util.hpp +5 -2
- package/src/duckdb/src/include/duckdb/common/arrow/result_arrow_wrapper.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/arrow/schema_metadata.hpp +11 -4
- package/src/duckdb/src/include/duckdb/common/assert.hpp +12 -1
- package/src/duckdb/src/include/duckdb/common/atomic_ptr.hpp +102 -0
- package/src/duckdb/src/include/duckdb/common/box_renderer.hpp +65 -6
- package/src/duckdb/src/include/duckdb/common/chrono.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/column_index.hpp +72 -0
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +120 -0
- package/src/duckdb/src/include/duckdb/{core_functions/core_functions.hpp → common/enums/collation_type.hpp} +2 -7
- package/src/duckdb/src/include/duckdb/common/enums/compression_type.hpp +5 -2
- package/src/duckdb/src/include/duckdb/common/enums/function_errors.hpp +18 -0
- package/src/duckdb/src/include/duckdb/common/enums/memory_tag.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/enums/metric_type.hpp +7 -2
- package/src/duckdb/src/include/duckdb/common/enums/optimizer_type.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/enums/order_preservation_type.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/profiler_format.hpp +1 -1
- package/src/duckdb/src/include/duckdb/{core_functions/aggregate → common/enums}/quantile_enum.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/enums/scan_vector_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/error_data.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/exception/parser_exception.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/exception.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/extension_type_info.hpp +37 -0
- package/src/duckdb/src/include/duckdb/common/extra_operator_info.hpp +7 -2
- package/src/duckdb/src/include/duckdb/common/extra_type_info.hpp +9 -3
- package/src/duckdb/src/include/duckdb/common/fast_mem.hpp +6 -6
- package/src/duckdb/src/include/duckdb/common/file_buffer.hpp +19 -10
- package/src/duckdb/src/include/duckdb/common/file_opener.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/fsst.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/helper.hpp +6 -0
- package/src/duckdb/src/include/duckdb/common/hugeint.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/insertion_order_preserving_map.hpp +12 -2
- package/src/duckdb/src/include/duckdb/common/local_file_system.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/multi_file_list.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +147 -27
- package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/numeric_utils.hpp +2 -7
- package/src/duckdb/src/include/duckdb/common/opener_file_system.hpp +16 -5
- package/src/duckdb/src/include/duckdb/common/operator/cast_operators.hpp +16 -0
- package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/platform.hpp +34 -3
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +10 -13
- package/src/duckdb/src/include/duckdb/common/random_engine.hpp +8 -3
- package/src/duckdb/src/include/duckdb/common/row_operations/row_operations.hpp +0 -2
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/serializer/memory_stream.hpp +7 -0
- package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/serializer/serializer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/stacktrace.hpp +25 -0
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +30 -2
- package/src/duckdb/src/include/duckdb/common/tree_renderer/graphviz_tree_renderer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/tree_renderer/html_tree_renderer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/tree_renderer/json_tree_renderer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/tree_renderer/text_tree_renderer.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/tree_renderer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/type_util.hpp +8 -0
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_allocator.hpp +8 -0
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +13 -2
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection_segment.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/types/conflict_manager.hpp +21 -4
- package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +4 -1
- package/src/duckdb/src/include/duckdb/common/types/date.hpp +9 -4
- package/src/duckdb/src/include/duckdb/common/types/date_lookup_cache.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/interval.hpp +58 -10
- package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +0 -4
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_allocator.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +43 -16
- package/src/duckdb/src/include/duckdb/common/types/uuid.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +63 -21
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +62 -16
- package/src/duckdb/src/include/duckdb/common/types/varint.hpp +13 -0
- package/src/duckdb/src/include/duckdb/common/types/vector.hpp +34 -7
- package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +15 -0
- package/src/duckdb/src/include/duckdb/common/types.hpp +12 -7
- package/src/duckdb/src/include/duckdb/common/uhugeint.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/vector_operations/aggregate_executor.hpp +12 -13
- package/src/duckdb/src/include/duckdb/common/vector_operations/binary_executor.hpp +27 -0
- package/src/duckdb/src/include/duckdb/common/vector_operations/unary_executor.hpp +111 -4
- package/src/duckdb/src/include/duckdb/common/vector_operations/vector_operations.hpp +0 -1
- package/src/duckdb/src/include/duckdb/execution/adaptive_filter.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +48 -10
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/expression_executor.hpp +0 -1
- package/src/duckdb/src/include/duckdb/execution/ht_entry.hpp +25 -27
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +28 -18
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +1 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/index/bound_index.hpp +23 -16
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_allocator.hpp +4 -0
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_buffer.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +25 -16
- package/src/duckdb/src/include/duckdb/execution/merge_sort_tree.hpp +15 -10
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/{persistent/physical_fixed_batch_copy.hpp → aggregate/physical_partitioned_aggregate.hpp} +25 -27
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +5 -4
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/ungrouped_aggregate_state.hpp +21 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/base_scanner.hpp +38 -9
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_buffer.hpp +8 -9
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_buffer_manager.hpp +7 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_error.hpp +29 -23
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_handle.hpp +15 -13
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_scanner.hpp +13 -5
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_option.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_reader_options.hpp +24 -10
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_schema.hpp +36 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state.hpp +21 -13
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp +52 -22
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine_cache.hpp +6 -6
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_validator.hpp +58 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/encode/csv_encoder.hpp +62 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/global_csv_state.hpp +6 -3
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner_boundary.hpp +16 -6
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/sniffer/csv_sniffer.hpp +9 -4
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine_options.hpp +8 -4
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/string_value_scanner.hpp +55 -10
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_buffered_batch_collector.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/join_filter_pushdown.hpp +28 -7
- package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +6 -9
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +17 -16
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +7 -3
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_copy_to_file.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +55 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_tableinout_function.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +10 -9
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_art_index.hpp +16 -13
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_cte.hpp +0 -4
- package/src/duckdb/src/include/duckdb/execution/partition_info.hpp +79 -0
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +20 -9
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +1 -11
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/progress_data.hpp +58 -0
- package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/reservoir_sample.hpp +160 -31
- package/src/duckdb/src/include/duckdb/function/aggregate/distributive_function_utils.hpp +31 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +61 -10
- package/src/duckdb/src/include/duckdb/{core_functions → function}/aggregate/minmax_n_helpers.hpp +1 -1
- package/src/duckdb/src/include/duckdb/{core_functions → function}/aggregate/sort_key_helpers.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +47 -27
- package/src/duckdb/src/include/duckdb/function/aggregate_state.hpp +2 -0
- package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +3 -10
- package/src/duckdb/src/include/duckdb/function/cast/bound_cast_data.hpp +13 -6
- package/src/duckdb/src/include/duckdb/function/compression/compression.hpp +15 -0
- package/src/duckdb/src/include/duckdb/function/compression_function.hpp +29 -6
- package/src/duckdb/src/include/duckdb/{core_functions → function}/create_sort_key.hpp +4 -1
- package/src/duckdb/src/include/duckdb/function/encoding_function.hpp +78 -0
- package/src/duckdb/src/include/duckdb/function/function.hpp +22 -1
- package/src/duckdb/src/include/duckdb/function/function_binder.hpp +3 -0
- package/src/duckdb/src/include/duckdb/function/function_list.hpp +39 -0
- package/src/duckdb/src/include/duckdb/function/function_set.hpp +13 -7
- package/src/duckdb/src/include/duckdb/{core_functions → function}/lambda_functions.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/partition_stats.hpp +36 -0
- package/src/duckdb/src/include/duckdb/function/register_function_list_helper.hpp +69 -0
- package/src/duckdb/src/include/duckdb/function/scalar/compressed_materialization_functions.hpp +154 -23
- package/src/duckdb/src/include/duckdb/function/scalar/compressed_materialization_utils.hpp +45 -0
- package/src/duckdb/src/include/duckdb/function/scalar/date_functions.hpp +45 -0
- package/src/duckdb/src/include/duckdb/function/scalar/generic_common.hpp +36 -0
- package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +32 -23
- package/src/duckdb/src/include/duckdb/function/scalar/list/contains_or_position.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar/list_functions.hpp +156 -0
- package/src/duckdb/src/include/duckdb/function/scalar/map_functions.hpp +27 -0
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +4 -45
- package/src/duckdb/src/include/duckdb/function/scalar/operator_functions.hpp +102 -0
- package/src/duckdb/src/include/duckdb/function/scalar/operators.hpp +2 -16
- package/src/duckdb/src/include/duckdb/function/scalar/sequence_functions.hpp +16 -25
- package/src/duckdb/src/include/duckdb/function/scalar/sequence_utils.hpp +38 -0
- package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/string_common.hpp +49 -0
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +401 -76
- package/src/duckdb/src/include/duckdb/function/scalar/struct_functions.hpp +63 -0
- package/src/duckdb/src/include/duckdb/function/scalar/struct_utils.hpp +33 -0
- package/src/duckdb/src/include/duckdb/function/scalar/system_functions.hpp +45 -0
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +17 -8
- package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_duck_schema.hpp +59 -6
- package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_type_info.hpp +12 -9
- package/src/duckdb/src/include/duckdb/function/table/arrow/enum/arrow_type_info_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +18 -13
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +7 -4
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +14 -0
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +15 -10
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +94 -18
- package/src/duckdb/src/include/duckdb/{core_functions → function}/to_interval.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/window/window_aggregate_function.hpp +44 -0
- package/src/duckdb/src/include/duckdb/function/window/window_aggregate_states.hpp +56 -0
- package/src/duckdb/src/include/duckdb/function/window/window_aggregator.hpp +194 -0
- package/src/duckdb/src/include/duckdb/function/window/window_boundaries_state.hpp +153 -0
- package/src/duckdb/src/include/duckdb/function/window/window_collection.hpp +146 -0
- package/src/duckdb/src/include/duckdb/function/window/window_constant_aggregator.hpp +38 -0
- package/src/duckdb/src/include/duckdb/function/window/window_custom_aggregator.hpp +32 -0
- package/src/duckdb/src/include/duckdb/function/window/window_distinct_aggregator.hpp +39 -0
- package/src/duckdb/src/include/duckdb/function/window/window_executor.hpp +122 -0
- package/src/duckdb/src/include/duckdb/function/window/window_index_tree.hpp +42 -0
- package/src/duckdb/src/include/duckdb/function/window/window_merge_sort_tree.hpp +108 -0
- package/src/duckdb/src/include/duckdb/function/window/window_naive_aggregator.hpp +33 -0
- package/src/duckdb/src/include/duckdb/function/window/window_rank_function.hpp +63 -0
- package/src/duckdb/src/include/duckdb/function/window/window_rownumber_function.hpp +43 -0
- package/src/duckdb/src/include/duckdb/function/window/window_segment_tree.hpp +31 -0
- package/src/duckdb/src/include/duckdb/function/window/window_shared_expressions.hpp +76 -0
- package/src/duckdb/src/include/duckdb/function/window/window_token_tree.hpp +46 -0
- package/src/duckdb/src/include/duckdb/function/window/window_value_function.hpp +79 -0
- package/src/duckdb/src/include/duckdb/logging/http_logger.hpp +2 -0
- package/src/duckdb/src/include/duckdb/logging/log_manager.hpp +81 -0
- package/src/duckdb/src/include/duckdb/logging/log_storage.hpp +127 -0
- package/src/duckdb/src/include/duckdb/logging/logger.hpp +287 -0
- package/src/duckdb/src/include/duckdb/logging/logging.hpp +83 -0
- package/src/duckdb/src/include/duckdb/main/appender.hpp +41 -18
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +6 -3
- package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +7 -2
- package/src/duckdb/src/include/duckdb/main/capi/extension_api.hpp +317 -231
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +17 -1
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +28 -6
- package/src/duckdb/src/include/duckdb/main/client_context_file_opener.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/client_context_wrapper.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +3 -2
- package/src/duckdb/src/include/duckdb/main/client_properties.hpp +8 -3
- package/src/duckdb/src/include/duckdb/main/config.hpp +52 -8
- package/src/duckdb/src/include/duckdb/main/connection.hpp +18 -3
- package/src/duckdb/src/include/duckdb/main/database.hpp +8 -7
- package/src/duckdb/src/include/duckdb/main/database_file_opener.hpp +5 -1
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/db_instance_cache.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/extension.hpp +8 -2
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +548 -9
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +18 -0
- package/src/duckdb/src/include/duckdb/main/extension_util.hpp +12 -7
- package/src/duckdb/src/include/duckdb/main/prepared_statement.hpp +3 -3
- package/src/duckdb/src/include/duckdb/main/profiling_info.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/query_profiler.hpp +8 -4
- package/src/duckdb/src/include/duckdb/main/relation/create_table_relation.hpp +3 -1
- package/src/duckdb/src/include/duckdb/main/relation/delete_relation.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/relation/subquery_relation.hpp +1 -4
- package/src/duckdb/src/include/duckdb/main/relation/table_function_relation.hpp +3 -1
- package/src/duckdb/src/include/duckdb/main/relation/table_relation.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/relation/update_relation.hpp +3 -2
- package/src/duckdb/src/include/duckdb/main/relation/value_relation.hpp +7 -0
- package/src/duckdb/src/include/duckdb/main/relation/view_relation.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/relation/write_parquet_relation.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/relation.hpp +45 -9
- package/src/duckdb/src/include/duckdb/main/secret/secret_storage.hpp +20 -22
- package/src/duckdb/src/include/duckdb/main/settings.hpp +613 -378
- package/src/duckdb/src/include/duckdb/main/table_description.hpp +14 -4
- package/src/duckdb/src/include/duckdb/optimizer/build_probe_side_optimizer.hpp +1 -3
- package/src/duckdb/src/include/duckdb/optimizer/column_lifetime_analyzer.hpp +14 -7
- package/src/duckdb/src/include/duckdb/optimizer/common_aggregate_optimizer.hpp +2 -2
- package/src/duckdb/src/include/duckdb/optimizer/empty_result_pullup.hpp +27 -0
- package/src/duckdb/src/include/duckdb/optimizer/expression_heuristics.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/filter_combiner.hpp +6 -1
- package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +2 -0
- package/src/duckdb/src/include/duckdb/optimizer/in_clause_rewriter.hpp +3 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_filter_pushdown_optimizer.hpp +5 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/plan_enumerator.hpp +2 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/relation_statistics_helper.hpp +2 -2
- package/src/duckdb/src/include/duckdb/optimizer/late_materialization.hpp +45 -0
- package/src/duckdb/src/include/duckdb/optimizer/matcher/expression_matcher.hpp +23 -0
- package/src/duckdb/src/include/duckdb/optimizer/matcher/type_matcher.hpp +18 -0
- package/src/duckdb/src/include/duckdb/optimizer/optimizer.hpp +9 -0
- package/src/duckdb/src/include/duckdb/optimizer/remove_unused_columns.hpp +33 -11
- package/src/duckdb/src/include/duckdb/optimizer/rule/distinct_aggregate_optimizer.hpp +34 -0
- package/src/duckdb/src/include/duckdb/optimizer/sampling_pushdown.hpp +25 -0
- package/src/duckdb/src/include/duckdb/optimizer/statistics_propagator.hpp +3 -1
- package/src/duckdb/src/include/duckdb/optimizer/sum_rewriter.hpp +37 -0
- package/src/duckdb/src/include/duckdb/optimizer/topn_optimizer.hpp +4 -0
- package/src/duckdb/src/include/duckdb/parallel/event.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +26 -8
- package/src/duckdb/src/include/duckdb/parallel/thread_context.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/base_expression.hpp +51 -3
- package/src/duckdb/src/include/duckdb/parser/constraints/unique_constraint.hpp +28 -44
- package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +6 -6
- package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +11 -1
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +12 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_scalar_function_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +22 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +3 -4
- package/src/duckdb/src/include/duckdb/parser/parsed_data/comment_on_column_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_function_info.hpp +16 -12
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +3 -3
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +5 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/sample_options.hpp +12 -3
- package/src/duckdb/src/include/duckdb/parser/parser.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/qualified_name.hpp +17 -57
- package/src/duckdb/src/include/duckdb/parser/qualified_name_set.hpp +19 -3
- package/src/duckdb/src/include/duckdb/parser/simplified_token.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +12 -9
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +45 -28
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +23 -11
- package/src/duckdb/src/include/duckdb/planner/binding_alias.hpp +44 -0
- package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/collation_binding.hpp +4 -3
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_unique_constraint.hpp +11 -10
- package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_function_expression.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_subquery_expression.hpp +4 -4
- package/src/duckdb/src/include/duckdb/planner/expression/bound_window_expression.hpp +6 -0
- package/src/duckdb/src/include/duckdb/planner/expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/having_binder.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +9 -4
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +8 -2
- package/src/duckdb/src/include/duckdb/planner/filter/conjunction_filter.hpp +1 -2
- package/src/duckdb/src/include/duckdb/planner/filter/dynamic_filter.hpp +48 -0
- package/src/duckdb/src/include/duckdb/planner/filter/in_filter.hpp +37 -0
- package/src/duckdb/src/include/duckdb/planner/filter/optional_filter.hpp +35 -0
- package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/logical_operator_visitor.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +9 -9
- package/src/duckdb/src/include/duckdb/planner/operator/logical_filter.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +16 -7
- package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_join.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_order.hpp +5 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_top_n.hpp +5 -3
- package/src/duckdb/src/include/duckdb/planner/table_binding.hpp +14 -6
- package/src/duckdb/src/include/duckdb/planner/table_filter.hpp +12 -8
- package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/block_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +82 -26
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_handle.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +10 -3
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/checkpoint/string_checkpoint_state.hpp +4 -13
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_compress.hpp +14 -15
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_constants.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_compress.hpp +13 -15
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/dictionary/analyze.hpp +46 -0
- package/src/duckdb/src/include/duckdb/storage/compression/dictionary/common.hpp +60 -0
- package/src/duckdb/src/include/duckdb/storage/compression/dictionary/compression.hpp +61 -0
- package/src/duckdb/src/include/duckdb/storage/compression/dictionary/decompression.hpp +50 -0
- package/src/duckdb/src/include/duckdb/storage/compression/empty_validity.hpp +100 -0
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/roaring/appender.hpp +150 -0
- package/src/duckdb/src/include/duckdb/storage/compression/roaring/roaring.hpp +618 -0
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +53 -31
- package/src/duckdb/src/include/duckdb/storage/index.hpp +2 -3
- package/src/duckdb/src/include/duckdb/storage/object_cache.hpp +0 -1
- package/src/duckdb/src/include/duckdb/storage/segment/uncompressed.hpp +4 -1
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/statistics/column_statistics.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +5 -4
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +16 -1
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/storage_index.hpp +70 -0
- package/src/duckdb/src/include/duckdb/storage/storage_info.hpp +5 -7
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +4 -3
- package/src/duckdb/src/include/duckdb/storage/storage_options.hpp +23 -0
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +34 -6
- package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/table/array_column_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +39 -10
- package/src/duckdb/src/include/duckdb/storage/table/column_data_checkpointer.hpp +56 -14
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +35 -29
- package/src/duckdb/src/include/duckdb/storage/table/delete_state.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +7 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +19 -6
- package/src/duckdb/src/include/duckdb/storage/table/row_version_manager.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +29 -6
- package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +10 -10
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +5 -0
- package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +26 -19
- package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +8 -1
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +16 -14
- package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/table_io_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/table_storage_info.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/temporary_file_manager.hpp +228 -61
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +14 -10
- package/src/duckdb/src/include/duckdb/transaction/commit_state.hpp +3 -1
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction.hpp +3 -2
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction_manager.hpp +1 -0
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +19 -17
- package/src/duckdb/src/include/duckdb/transaction/rollback_state.hpp +5 -2
- package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +1 -2
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +13 -8
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer_allocator.hpp +79 -0
- package/src/duckdb/src/include/duckdb/transaction/update_info.hpp +43 -13
- package/src/duckdb/src/include/duckdb/transaction/wal_write_state.hpp +4 -1
- package/src/duckdb/src/include/duckdb/verification/copied_statement_verifier.hpp +4 -2
- package/src/duckdb/src/include/duckdb/verification/deserialized_statement_verifier.hpp +4 -2
- package/src/duckdb/src/include/duckdb/verification/external_statement_verifier.hpp +4 -2
- package/src/duckdb/src/include/duckdb/verification/fetch_row_verifier.hpp +4 -2
- package/src/duckdb/src/include/duckdb/verification/no_operator_caching_verifier.hpp +4 -2
- package/src/duckdb/src/include/duckdb/verification/parsed_statement_verifier.hpp +4 -2
- package/src/duckdb/src/include/duckdb/verification/prepared_statement_verifier.hpp +7 -3
- package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +11 -5
- package/src/duckdb/src/include/duckdb/verification/unoptimized_statement_verifier.hpp +4 -2
- package/src/duckdb/src/include/duckdb.h +424 -41
- package/src/duckdb/src/include/duckdb_extension.h +301 -195
- package/src/duckdb/src/logging/log_manager.cpp +157 -0
- package/src/duckdb/src/logging/log_storage.cpp +209 -0
- package/src/duckdb/src/logging/logger.cpp +211 -0
- package/src/duckdb/src/logging/logging.cpp +42 -0
- package/src/duckdb/src/main/appender.cpp +187 -45
- package/src/duckdb/src/main/attached_database.cpp +16 -8
- package/src/duckdb/src/main/capi/appender-c.cpp +47 -4
- package/src/duckdb/src/main/capi/arrow-c.cpp +9 -4
- package/src/duckdb/src/main/capi/config-c.cpp +17 -4
- package/src/duckdb/src/main/capi/datetime-c.cpp +15 -0
- package/src/duckdb/src/main/capi/duckdb-c.cpp +54 -13
- package/src/duckdb/src/main/capi/duckdb_value-c.cpp +212 -4
- package/src/duckdb/src/main/capi/helper-c.cpp +3 -0
- package/src/duckdb/src/main/capi/prepared-c.cpp +26 -7
- package/src/duckdb/src/main/capi/replacement_scan-c.cpp +1 -1
- package/src/duckdb/src/main/capi/result-c.cpp +3 -0
- package/src/duckdb/src/main/capi/table_description-c.cpp +43 -10
- package/src/duckdb/src/main/capi/threading-c.cpp +4 -4
- package/src/duckdb/src/main/client_context.cpp +125 -51
- package/src/duckdb/src/main/client_context_file_opener.cpp +4 -0
- package/src/duckdb/src/main/client_context_wrapper.cpp +4 -0
- package/src/duckdb/src/main/client_data.cpp +1 -1
- package/src/duckdb/src/main/client_verify.cpp +39 -20
- package/src/duckdb/src/main/config.cpp +266 -74
- package/src/duckdb/src/main/connection.cpp +53 -13
- package/src/duckdb/src/main/database.cpp +39 -18
- package/src/duckdb/src/main/database_manager.cpp +12 -11
- package/src/duckdb/src/main/db_instance_cache.cpp +14 -7
- package/src/duckdb/src/main/extension/extension_helper.cpp +24 -23
- package/src/duckdb/src/main/extension/extension_install.cpp +19 -7
- package/src/duckdb/src/main/extension/extension_load.cpp +91 -41
- package/src/duckdb/src/main/extension/extension_util.cpp +40 -19
- package/src/duckdb/src/main/extension.cpp +20 -11
- package/src/duckdb/src/main/profiling_info.cpp +19 -5
- package/src/duckdb/src/main/query_profiler.cpp +135 -36
- package/src/duckdb/src/main/query_result.cpp +2 -1
- package/src/duckdb/src/main/relation/aggregate_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/create_table_relation.cpp +5 -4
- package/src/duckdb/src/main/relation/create_view_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/cross_product_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/delete_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/delim_get_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/distinct_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/explain_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/filter_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/insert_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/join_relation.cpp +5 -5
- package/src/duckdb/src/main/relation/order_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/projection_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/query_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/read_csv_relation.cpp +58 -20
- package/src/duckdb/src/main/relation/setop_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/subquery_relation.cpp +3 -8
- package/src/duckdb/src/main/relation/table_function_relation.cpp +10 -1
- package/src/duckdb/src/main/relation/table_relation.cpp +19 -3
- package/src/duckdb/src/main/relation/update_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/value_relation.cpp +42 -2
- package/src/duckdb/src/main/relation/view_relation.cpp +8 -2
- package/src/duckdb/src/main/relation/write_csv_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/write_parquet_relation.cpp +1 -1
- package/src/duckdb/src/main/relation.cpp +49 -28
- package/src/duckdb/src/main/secret/secret_manager.cpp +1 -1
- package/src/duckdb/src/main/secret/secret_storage.cpp +6 -4
- package/src/duckdb/src/main/settings/autogenerated_settings.cpp +1102 -0
- package/src/duckdb/src/main/settings/custom_settings.cpp +1343 -0
- package/src/duckdb/src/optimizer/build_probe_side_optimizer.cpp +60 -37
- package/src/duckdb/src/optimizer/column_binding_replacer.cpp +1 -1
- package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +126 -72
- package/src/duckdb/src/optimizer/common_aggregate_optimizer.cpp +22 -6
- package/src/duckdb/src/optimizer/compressed_materialization/compress_aggregate.cpp +3 -3
- package/src/duckdb/src/optimizer/compressed_materialization/compress_distinct.cpp +2 -2
- package/src/duckdb/src/optimizer/compressed_materialization.cpp +3 -3
- package/src/duckdb/src/optimizer/cse_optimizer.cpp +7 -7
- package/src/duckdb/src/optimizer/deliminator.cpp +6 -5
- package/src/duckdb/src/optimizer/empty_result_pullup.cpp +96 -0
- package/src/duckdb/src/optimizer/expression_heuristics.cpp +11 -3
- package/src/duckdb/src/optimizer/expression_rewriter.cpp +9 -2
- package/src/duckdb/src/optimizer/filter_combiner.cpp +190 -88
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +6 -5
- package/src/duckdb/src/optimizer/in_clause_rewriter.cpp +25 -9
- package/src/duckdb/src/optimizer/join_filter_pushdown_optimizer.cpp +170 -72
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +5 -4
- package/src/duckdb/src/optimizer/join_order/plan_enumerator.cpp +3 -1
- package/src/duckdb/src/optimizer/join_order/query_graph_manager.cpp +7 -7
- package/src/duckdb/src/optimizer/join_order/relation_manager.cpp +15 -6
- package/src/duckdb/src/optimizer/join_order/relation_statistics_helper.cpp +37 -22
- package/src/duckdb/src/optimizer/late_materialization.cpp +414 -0
- package/src/duckdb/src/optimizer/limit_pushdown.cpp +1 -0
- package/src/duckdb/src/optimizer/matcher/expression_matcher.cpp +30 -2
- package/src/duckdb/src/optimizer/optimizer.cpp +67 -7
- package/src/duckdb/src/optimizer/pullup/pullup_filter.cpp +3 -3
- package/src/duckdb/src/optimizer/pullup/pullup_projection.cpp +2 -2
- package/src/duckdb/src/optimizer/pullup/pullup_set_operation.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_aggregate.cpp +2 -2
- package/src/duckdb/src/optimizer/pushdown/pushdown_filter.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_left_join.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_mark_join.cpp +3 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_projection.cpp +5 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_set_operation.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_unnest.cpp +52 -0
- package/src/duckdb/src/optimizer/pushdown/pushdown_window.cpp +2 -2
- package/src/duckdb/src/optimizer/regex_range_filter.cpp +1 -1
- package/src/duckdb/src/optimizer/remove_duplicate_groups.cpp +1 -1
- package/src/duckdb/src/optimizer/remove_unused_columns.cpp +168 -38
- package/src/duckdb/src/optimizer/rule/arithmetic_simplification.cpp +2 -1
- package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +8 -5
- package/src/duckdb/src/optimizer/rule/conjunction_simplification.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/constant_folding.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/distinct_aggregate_optimizer.cpp +65 -0
- package/src/duckdb/src/optimizer/rule/distributivity.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/enum_comparison.cpp +2 -1
- package/src/duckdb/src/optimizer/rule/equal_or_null_simplification.cpp +4 -3
- package/src/duckdb/src/optimizer/rule/in_clause_simplification_rule.cpp +3 -3
- package/src/duckdb/src/optimizer/rule/like_optimizations.cpp +3 -1
- package/src/duckdb/src/optimizer/rule/move_constants.cpp +9 -9
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +4 -3
- package/src/duckdb/src/optimizer/rule/timestamp_comparison.cpp +1 -1
- package/src/duckdb/src/optimizer/sampling_pushdown.cpp +24 -0
- package/src/duckdb/src/optimizer/statistics/expression/propagate_comparison.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/expression/propagate_conjunction.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/expression/propagate_operator.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/operator/propagate_aggregate.cpp +74 -0
- package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +10 -7
- package/src/duckdb/src/optimizer/statistics/operator/propagate_get.cpp +3 -3
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +3 -3
- package/src/duckdb/src/optimizer/statistics/operator/propagate_window.cpp +3 -0
- package/src/duckdb/src/optimizer/sum_rewriter.cpp +174 -0
- package/src/duckdb/src/optimizer/topn_optimizer.cpp +71 -0
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +5 -5
- package/src/duckdb/src/parallel/event.cpp +4 -0
- package/src/duckdb/src/parallel/executor.cpp +11 -29
- package/src/duckdb/src/parallel/executor_task.cpp +8 -3
- package/src/duckdb/src/parallel/pipeline.cpp +15 -8
- package/src/duckdb/src/parallel/pipeline_executor.cpp +67 -43
- package/src/duckdb/src/parallel/thread_context.cpp +12 -1
- package/src/duckdb/src/parser/column_definition.cpp +3 -3
- package/src/duckdb/src/parser/constraints/unique_constraint.cpp +72 -9
- package/src/duckdb/src/parser/expression/columnref_expression.cpp +15 -3
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/function_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/lambda_expression.cpp +3 -3
- package/src/duckdb/src/parser/expression/lambdaref_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/star_expression.cpp +46 -2
- package/src/duckdb/src/parser/expression/window_expression.cpp +24 -1
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +26 -2
- package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +5 -3
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +29 -1
- package/src/duckdb/src/parser/parsed_data/attach_info.cpp +6 -6
- package/src/duckdb/src/parser/parsed_data/create_aggregate_function_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_function_info.cpp +17 -0
- package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +16 -15
- package/src/duckdb/src/parser/parsed_data/create_macro_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_pragma_function_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -2
- package/src/duckdb/src/parser/parsed_data/create_schema_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +1 -0
- package/src/duckdb/src/parser/parsed_data/create_type_info.cpp +4 -4
- package/src/duckdb/src/parser/parsed_data/load_info.cpp +1 -0
- package/src/duckdb/src/parser/parsed_data/sample_options.cpp +31 -1
- package/src/duckdb/src/parser/parsed_expression.cpp +1 -1
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +4 -1
- package/src/duckdb/src/parser/parser.cpp +129 -0
- package/src/duckdb/src/parser/qualified_name.cpp +99 -0
- package/src/duckdb/src/parser/query_error_context.cpp +35 -6
- package/src/duckdb/src/parser/query_node/select_node.cpp +4 -4
- package/src/duckdb/src/parser/statement/delete_statement.cpp +6 -1
- package/src/duckdb/src/parser/statement/insert_statement.cpp +4 -3
- package/src/duckdb/src/parser/statement/update_statement.cpp +6 -1
- package/src/duckdb/src/parser/tableref/pivotref.cpp +2 -2
- package/src/duckdb/src/parser/tableref.cpp +2 -2
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +16 -24
- package/src/duckdb/src/parser/transform/expression/transform_array_access.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_bool_expr.cpp +5 -5
- package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +61 -13
- package/src/duckdb/src/parser/transform/expression/transform_constant.cpp +10 -4
- package/src/duckdb/src/parser/transform/expression/transform_expression.cpp +2 -2
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +30 -3
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_subquery.cpp +25 -6
- package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +1 -1
- package/src/duckdb/src/parser/transform/helpers/transform_sample.cpp +10 -3
- package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +4 -3
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +18 -3
- package/src/duckdb/src/parser/transform/statement/transform_comment_on.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +0 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +5 -5
- package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +26 -12
- package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +11 -3
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +2 -0
- package/src/duckdb/src/parser/transform/statement/transform_pragma.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_prepare.cpp +4 -4
- package/src/duckdb/src/parser/transform/statement/transform_set.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_show.cpp +21 -3
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +8 -6
- package/src/duckdb/src/parser/transformer.cpp +2 -2
- package/src/duckdb/src/planner/bind_context.cpp +308 -136
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +30 -31
- package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +4 -2
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +102 -94
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +7 -5
- package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +7 -7
- package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +10 -10
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +24 -6
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +23 -15
- package/src/duckdb/src/planner/binder/expression/bind_parameter_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +97 -19
- package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +74 -16
- package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +49 -15
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +32 -23
- package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +20 -3
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +2 -2
- package/src/duckdb/src/planner/binder/query_node/plan_query_node.cpp +3 -0
- package/src/duckdb/src/planner/binder/query_node/plan_setop.cpp +6 -5
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +38 -19
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +2 -12
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +117 -412
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +423 -144
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +5 -0
- package/src/duckdb/src/planner/binder/statement/bind_execute.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +0 -4
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +31 -13
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +96 -27
- package/src/duckdb/src/planner/binder/statement/bind_summarize.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +5 -3
- package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +7 -6
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +36 -9
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +34 -34
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +72 -35
- package/src/duckdb/src/planner/binder/tableref/bind_showref.cpp +99 -18
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +23 -11
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +22 -19
- package/src/duckdb/src/planner/binder.cpp +23 -45
- package/src/duckdb/src/planner/binding_alias.cpp +69 -0
- package/src/duckdb/src/planner/bound_parameter_map.cpp +1 -1
- package/src/duckdb/src/planner/bound_result_modifier.cpp +6 -2
- package/src/duckdb/src/planner/collation_binding.cpp +38 -4
- package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +17 -5
- package/src/duckdb/src/planner/expression/bound_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_function_expression.cpp +8 -1
- package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_window_expression.cpp +24 -4
- package/src/duckdb/src/planner/expression.cpp +7 -1
- package/src/duckdb/src/planner/expression_binder/aggregate_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/group_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/having_binder.cpp +16 -0
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +53 -1
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/order_binder.cpp +8 -8
- package/src/duckdb/src/planner/expression_binder/relation_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/select_bind_state.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/table_function_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/update_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder.cpp +7 -7
- package/src/duckdb/src/planner/expression_iterator.cpp +6 -3
- package/src/duckdb/src/planner/filter/constant_filter.cpp +17 -2
- package/src/duckdb/src/planner/filter/dynamic_filter.cpp +68 -0
- package/src/duckdb/src/planner/filter/in_filter.cpp +84 -0
- package/src/duckdb/src/planner/filter/null_filter.cpp +1 -2
- package/src/duckdb/src/planner/filter/optional_filter.cpp +29 -0
- package/src/duckdb/src/planner/filter/struct_filter.cpp +11 -6
- package/src/duckdb/src/planner/joinside.cpp +6 -5
- package/src/duckdb/src/planner/logical_operator.cpp +4 -1
- package/src/duckdb/src/planner/logical_operator_visitor.cpp +68 -2
- package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +23 -0
- package/src/duckdb/src/planner/operator/logical_create_index.cpp +16 -12
- package/src/duckdb/src/planner/operator/logical_filter.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_get.cpp +48 -25
- package/src/duckdb/src/planner/operator/logical_insert.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_join.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_order.cpp +4 -11
- package/src/duckdb/src/planner/operator/logical_top_n.cpp +7 -0
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +33 -5
- package/src/duckdb/src/planner/subquery/rewrite_correlated_expressions.cpp +2 -2
- package/src/duckdb/src/planner/table_binding.cpp +74 -36
- package/src/duckdb/src/planner/table_filter.cpp +5 -8
- package/src/duckdb/src/storage/arena_allocator.cpp +5 -4
- package/src/duckdb/src/storage/buffer/block_handle.cpp +88 -17
- package/src/duckdb/src/storage/buffer/block_manager.cpp +34 -26
- package/src/duckdb/src/storage/buffer/buffer_handle.cpp +2 -2
- package/src/duckdb/src/storage/buffer/buffer_pool.cpp +70 -49
- package/src/duckdb/src/storage/buffer_manager.cpp +4 -0
- package/src/duckdb/src/storage/checkpoint_manager.cpp +24 -5
- package/src/duckdb/src/storage/compression/bitpacking.cpp +14 -16
- package/src/duckdb/src/storage/compression/dictionary/analyze.cpp +54 -0
- package/src/duckdb/src/storage/compression/dictionary/common.cpp +90 -0
- package/src/duckdb/src/storage/compression/dictionary/compression.cpp +174 -0
- package/src/duckdb/src/storage/compression/dictionary/decompression.cpp +115 -0
- package/src/duckdb/src/storage/compression/dictionary_compression.cpp +53 -545
- package/src/duckdb/src/storage/compression/empty_validity.cpp +15 -0
- package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +25 -16
- package/src/duckdb/src/storage/compression/fsst.cpp +101 -47
- package/src/duckdb/src/storage/compression/numeric_constant.cpp +92 -2
- package/src/duckdb/src/storage/compression/rle.cpp +216 -46
- package/src/duckdb/src/storage/compression/roaring/analyze.cpp +179 -0
- package/src/duckdb/src/storage/compression/roaring/common.cpp +282 -0
- package/src/duckdb/src/storage/compression/roaring/compress.cpp +481 -0
- package/src/duckdb/src/storage/compression/roaring/metadata.cpp +262 -0
- package/src/duckdb/src/storage/compression/roaring/scan.cpp +364 -0
- package/src/duckdb/src/storage/compression/string_uncompressed.cpp +47 -65
- package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +102 -39
- package/src/duckdb/src/storage/compression/zstd.cpp +1049 -0
- package/src/duckdb/src/storage/data_table.cpp +312 -172
- package/src/duckdb/src/storage/local_storage.cpp +104 -46
- package/src/duckdb/src/storage/metadata/metadata_manager.cpp +1 -1
- package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +7 -3
- package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +138 -58
- package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +14 -0
- package/src/duckdb/src/storage/serialization/serialize_parsed_expression.cpp +19 -8
- package/src/duckdb/src/storage/serialization/serialize_statement.cpp +2 -0
- package/src/duckdb/src/storage/serialization/serialize_table_filter.cpp +43 -0
- package/src/duckdb/src/storage/serialization/serialize_types.cpp +32 -5
- package/src/duckdb/src/storage/single_file_block_manager.cpp +6 -8
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +82 -71
- package/src/duckdb/src/storage/statistics/column_statistics.cpp +3 -3
- package/src/duckdb/src/storage/statistics/distinct_statistics.cpp +18 -17
- package/src/duckdb/src/storage/statistics/numeric_stats.cpp +34 -22
- package/src/duckdb/src/storage/statistics/string_stats.cpp +14 -3
- package/src/duckdb/src/storage/storage_info.cpp +72 -10
- package/src/duckdb/src/storage/storage_manager.cpp +41 -47
- package/src/duckdb/src/storage/table/array_column_data.cpp +7 -1
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +10 -9
- package/src/duckdb/src/storage/table/column_data.cpp +105 -43
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +307 -132
- package/src/duckdb/src/storage/table/column_segment.cpp +36 -13
- package/src/duckdb/src/storage/table/list_column_data.cpp +4 -4
- package/src/duckdb/src/storage/table/row_group.cpp +159 -66
- package/src/duckdb/src/storage/table/row_group_collection.cpp +157 -68
- package/src/duckdb/src/storage/table/row_version_manager.cpp +33 -10
- package/src/duckdb/src/storage/table/scan_state.cpp +21 -7
- package/src/duckdb/src/storage/table/standard_column_data.cpp +68 -5
- package/src/duckdb/src/storage/table/struct_column_data.cpp +42 -4
- package/src/duckdb/src/storage/table/table_statistics.cpp +91 -5
- package/src/duckdb/src/storage/table/update_segment.cpp +287 -210
- package/src/duckdb/src/storage/table_index_list.cpp +55 -58
- package/src/duckdb/src/storage/temporary_file_manager.cpp +412 -149
- package/src/duckdb/src/storage/wal_replay.cpp +132 -48
- package/src/duckdb/src/storage/write_ahead_log.cpp +75 -48
- package/src/duckdb/src/transaction/cleanup_state.cpp +0 -1
- package/src/duckdb/src/transaction/commit_state.cpp +23 -14
- package/src/duckdb/src/transaction/duck_transaction.cpp +29 -25
- package/src/duckdb/src/transaction/duck_transaction_manager.cpp +18 -6
- package/src/duckdb/src/transaction/meta_transaction.cpp +3 -2
- package/src/duckdb/src/transaction/rollback_state.cpp +5 -2
- package/src/duckdb/src/transaction/transaction_context.cpp +9 -1
- package/src/duckdb/src/transaction/undo_buffer.cpp +35 -27
- package/src/duckdb/src/transaction/undo_buffer_allocator.cpp +72 -0
- package/src/duckdb/src/transaction/wal_write_state.cpp +12 -10
- package/src/duckdb/src/verification/copied_statement_verifier.cpp +7 -4
- package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +7 -5
- package/src/duckdb/src/verification/external_statement_verifier.cpp +7 -4
- package/src/duckdb/src/verification/fetch_row_verifier.cpp +7 -4
- package/src/duckdb/src/verification/no_operator_caching_verifier.cpp +8 -4
- package/src/duckdb/src/verification/parsed_statement_verifier.cpp +7 -4
- package/src/duckdb/src/verification/prepared_statement_verifier.cpp +16 -12
- package/src/duckdb/src/verification/statement_verifier.cpp +20 -15
- package/src/duckdb/src/verification/unoptimized_statement_verifier.cpp +7 -4
- package/src/duckdb/third_party/fsst/libfsst.hpp +1 -0
- package/src/duckdb/third_party/httplib/httplib.hpp +15 -22
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +4 -2
- package/src/duckdb/third_party/libpg_query/pg_functions.cpp +2 -4
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +14278 -13832
- package/src/duckdb/third_party/parquet/parquet_types.cpp +3410 -1686
- package/src/duckdb/third_party/parquet/parquet_types.h +1585 -1204
- package/src/duckdb/third_party/skiplist/SkipList.h +0 -1
- package/src/duckdb/third_party/snappy/snappy-stubs-internal.h +13 -15
- package/src/duckdb/third_party/zstd/common/debug.cpp +36 -0
- package/src/duckdb/third_party/zstd/common/entropy_common.cpp +173 -49
- package/src/duckdb/third_party/zstd/common/error_private.cpp +11 -3
- package/src/duckdb/third_party/zstd/common/fse_decompress.cpp +126 -97
- package/src/duckdb/third_party/zstd/common/pool.cpp +376 -0
- package/src/duckdb/third_party/zstd/common/threading.cpp +193 -0
- package/src/duckdb/third_party/zstd/common/xxhash.cpp +18 -14
- package/src/duckdb/third_party/zstd/common/zstd_common.cpp +3 -38
- package/src/duckdb/third_party/zstd/compress/fse_compress.cpp +93 -165
- package/src/duckdb/third_party/zstd/compress/hist.cpp +28 -31
- package/src/duckdb/third_party/zstd/compress/huf_compress.cpp +957 -291
- package/src/duckdb/third_party/zstd/compress/zstd_compress.cpp +3988 -1124
- package/src/duckdb/third_party/zstd/compress/zstd_compress_literals.cpp +120 -43
- package/src/duckdb/third_party/zstd/compress/zstd_compress_sequences.cpp +47 -23
- package/src/duckdb/third_party/zstd/compress/zstd_compress_superblock.cpp +274 -424
- package/src/duckdb/third_party/zstd/compress/zstd_double_fast.cpp +403 -153
- package/src/duckdb/third_party/zstd/compress/zstd_fast.cpp +741 -268
- package/src/duckdb/third_party/zstd/compress/zstd_lazy.cpp +1339 -278
- package/src/duckdb/third_party/zstd/compress/zstd_ldm.cpp +334 -222
- package/src/duckdb/third_party/zstd/compress/zstd_opt.cpp +674 -298
- package/src/duckdb/third_party/zstd/compress/zstdmt_compress.cpp +1885 -0
- package/src/duckdb/third_party/zstd/decompress/huf_decompress.cpp +1247 -586
- package/src/duckdb/third_party/zstd/decompress/zstd_ddict.cpp +18 -17
- package/src/duckdb/third_party/zstd/decompress/zstd_decompress.cpp +724 -270
- package/src/duckdb/third_party/zstd/decompress/zstd_decompress_block.cpp +1193 -393
- package/src/duckdb/third_party/zstd/deprecated/zbuff_common.cpp +30 -0
- package/src/duckdb/third_party/zstd/deprecated/zbuff_compress.cpp +171 -0
- package/src/duckdb/third_party/zstd/deprecated/zbuff_decompress.cpp +80 -0
- package/src/duckdb/third_party/zstd/dict/cover.cpp +1271 -0
- package/src/duckdb/third_party/zstd/dict/divsufsort.cpp +1916 -0
- package/src/duckdb/third_party/zstd/dict/fastcover.cpp +775 -0
- package/src/duckdb/third_party/zstd/dict/zdict.cpp +1139 -0
- package/src/duckdb/third_party/zstd/include/zdict.h +473 -0
- package/src/duckdb/third_party/zstd/include/zstd/common/allocations.h +58 -0
- package/src/duckdb/third_party/zstd/include/zstd/common/bits.h +204 -0
- package/src/duckdb/third_party/zstd/include/zstd/common/bitstream.h +88 -85
- package/src/duckdb/third_party/zstd/include/zstd/common/compiler.h +243 -47
- package/src/duckdb/third_party/zstd/include/zstd/common/cpu.h +253 -0
- package/src/duckdb/third_party/zstd/include/zstd/common/debug.h +31 -31
- package/src/duckdb/third_party/zstd/include/zstd/common/error_private.h +94 -6
- package/src/duckdb/third_party/zstd/include/zstd/common/fse.h +424 -64
- package/src/duckdb/third_party/zstd/include/zstd/common/huf.h +255 -70
- package/src/duckdb/third_party/zstd/include/zstd/common/mem.h +125 -85
- package/src/duckdb/third_party/zstd/include/zstd/common/pool.h +84 -0
- package/src/duckdb/third_party/zstd/include/zstd/common/portability_macros.h +158 -0
- package/src/duckdb/third_party/zstd/include/zstd/common/threading.h +152 -0
- package/src/duckdb/third_party/zstd/include/zstd/common/{xxhash.h → xxhash.hpp} +0 -1
- package/src/duckdb/third_party/zstd/include/zstd/common/{xxhash_static.h → xxhash_static.hpp} +1 -1
- package/src/duckdb/third_party/zstd/include/zstd/common/zstd_deps.h +122 -0
- package/src/duckdb/third_party/zstd/include/zstd/common/zstd_internal.h +143 -174
- package/src/duckdb/third_party/zstd/include/zstd/common/zstd_trace.h +159 -0
- package/src/duckdb/third_party/zstd/include/zstd/compress/clevels.h +136 -0
- package/src/duckdb/third_party/zstd/include/zstd/compress/hist.h +4 -4
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_compress_internal.h +631 -220
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_compress_literals.h +17 -7
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_compress_sequences.h +2 -2
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_compress_superblock.h +3 -2
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_cwksp.h +256 -153
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_double_fast.h +16 -3
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_fast.h +4 -3
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_lazy.h +145 -11
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_ldm.h +14 -6
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_ldm_geartab.h +110 -0
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_opt.h +33 -9
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstdmt_compress.h +107 -0
- package/src/duckdb/third_party/zstd/include/zstd/decompress/zstd_ddict.h +4 -3
- package/src/duckdb/third_party/zstd/include/zstd/decompress/zstd_decompress_block.h +20 -6
- package/src/duckdb/third_party/zstd/include/zstd/decompress/zstd_decompress_internal.h +88 -16
- package/src/duckdb/third_party/zstd/include/zstd/deprecated/zbuff.h +214 -0
- package/src/duckdb/third_party/zstd/include/zstd/dict/cover.h +156 -0
- package/src/duckdb/third_party/zstd/include/zstd/dict/divsufsort.h +62 -0
- package/src/duckdb/third_party/zstd/include/zstd.h +2171 -93
- package/src/duckdb/third_party/zstd/include/{zstd/common/zstd_errors.h → zstd_errors.h} +32 -10
- package/src/duckdb/ub_extension_core_functions_aggregate_algebraic.cpp +8 -0
- package/src/duckdb/ub_extension_core_functions_aggregate_distributive.cpp +20 -0
- package/src/duckdb/ub_extension_core_functions_aggregate_holistic.cpp +12 -0
- package/src/duckdb/ub_extension_core_functions_aggregate_nested.cpp +6 -0
- package/src/duckdb/ub_extension_core_functions_aggregate_regression.cpp +14 -0
- package/src/duckdb/ub_extension_core_functions_scalar_array.cpp +4 -0
- package/src/duckdb/ub_extension_core_functions_scalar_bit.cpp +2 -0
- package/src/duckdb/ub_extension_core_functions_scalar_blob.cpp +4 -0
- package/src/duckdb/ub_extension_core_functions_scalar_date.cpp +20 -0
- package/src/duckdb/ub_extension_core_functions_scalar_debug.cpp +2 -0
- package/src/duckdb/ub_extension_core_functions_scalar_enum.cpp +2 -0
- package/src/duckdb/ub_extension_core_functions_scalar_generic.cpp +18 -0
- package/src/duckdb/ub_extension_core_functions_scalar_list.cpp +22 -0
- package/src/duckdb/ub_extension_core_functions_scalar_map.cpp +14 -0
- package/src/duckdb/ub_extension_core_functions_scalar_math.cpp +2 -0
- package/src/duckdb/ub_extension_core_functions_scalar_operators.cpp +2 -0
- package/src/duckdb/ub_extension_core_functions_scalar_random.cpp +4 -0
- package/src/duckdb/ub_extension_core_functions_scalar_string.cpp +48 -0
- package/src/duckdb/ub_extension_core_functions_scalar_struct.cpp +2 -0
- package/src/duckdb/ub_extension_core_functions_scalar_union.cpp +6 -0
- package/src/duckdb/ub_src_common.cpp +4 -0
- package/src/duckdb/ub_src_common_arrow.cpp +3 -1
- package/src/duckdb/ub_src_execution.cpp +0 -6
- package/src/duckdb/ub_src_execution_operator_aggregate.cpp +2 -0
- package/src/duckdb/ub_src_execution_operator_csv_scanner_encode.cpp +2 -0
- package/src/duckdb/ub_src_execution_operator_csv_scanner_util.cpp +2 -0
- package/src/duckdb/ub_src_execution_sample.cpp +4 -0
- package/src/duckdb/ub_src_function.cpp +6 -0
- package/src/duckdb/ub_src_function_aggregate.cpp +0 -2
- package/src/duckdb/ub_src_function_aggregate_distributive.cpp +3 -1
- package/src/duckdb/ub_src_function_scalar.cpp +2 -8
- package/src/duckdb/ub_src_function_scalar_date.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_generic.cpp +2 -2
- package/src/duckdb/ub_src_function_scalar_map.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_operator.cpp +8 -0
- package/src/duckdb/ub_src_function_scalar_string.cpp +10 -0
- package/src/duckdb/ub_src_function_scalar_struct.cpp +4 -0
- package/src/duckdb/ub_src_function_scalar_system.cpp +2 -0
- package/src/duckdb/ub_src_function_table_system.cpp +6 -0
- package/src/duckdb/ub_src_function_window.cpp +36 -0
- package/src/duckdb/ub_src_logging.cpp +8 -0
- package/src/duckdb/ub_src_main_settings.cpp +3 -1
- package/src/duckdb/ub_src_optimizer.cpp +8 -0
- package/src/duckdb/ub_src_optimizer_pushdown.cpp +2 -0
- package/src/duckdb/ub_src_optimizer_rule.cpp +2 -0
- package/src/duckdb/ub_src_parser.cpp +2 -0
- package/src/duckdb/ub_src_parser_parsed_data.cpp +2 -0
- package/src/duckdb/ub_src_planner.cpp +2 -0
- package/src/duckdb/ub_src_planner_filter.cpp +6 -0
- package/src/duckdb/ub_src_storage_compression.cpp +4 -0
- package/src/duckdb/ub_src_storage_compression_dictionary.cpp +8 -0
- package/src/duckdb/ub_src_storage_compression_roaring.cpp +10 -0
- package/src/duckdb/ub_src_transaction.cpp +2 -0
- package/vendor.py +1 -1
- package/src/duckdb/extension/json/yyjson/include/yyjson.hpp +0 -6003
- package/src/duckdb/extension/json/yyjson/yyjson.cpp +0 -8218
- package/src/duckdb/src/common/arrow/appender/list_data.cpp +0 -78
- package/src/duckdb/src/common/arrow/appender/map_data.cpp +0 -91
- package/src/duckdb/src/common/cycle_counter.cpp +0 -76
- package/src/duckdb/src/common/field_writer.cpp +0 -97
- package/src/duckdb/src/common/http_state.cpp +0 -95
- package/src/duckdb/src/common/preserved_error.cpp +0 -87
- package/src/duckdb/src/common/row_operations/row_match.cpp +0 -359
- package/src/duckdb/src/common/serializer/buffered_deserializer.cpp +0 -27
- package/src/duckdb/src/common/serializer/buffered_serializer.cpp +0 -36
- package/src/duckdb/src/common/serializer/format_serializer.cpp +0 -15
- package/src/duckdb/src/common/serializer.cpp +0 -24
- package/src/duckdb/src/common/types/chunk_collection.cpp +0 -190
- package/src/duckdb/src/core_functions/aggregate/distributive/entropy.cpp +0 -183
- package/src/duckdb/src/core_functions/scalar/date/current.cpp +0 -54
- package/src/duckdb/src/core_functions/scalar/list/list_cosine_similarity.cpp +0 -78
- package/src/duckdb/src/core_functions/scalar/list/list_inner_product.cpp +0 -70
- package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +0 -412
- package/src/duckdb/src/core_functions/scalar/secret/which_secret.cpp +0 -28
- package/src/duckdb/src/core_functions/scalar/string/jaro_winkler.cpp +0 -71
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +0 -238
- package/src/duckdb/src/execution/index/art/node16.cpp +0 -196
- package/src/duckdb/src/execution/index/art/node4.cpp +0 -189
- package/src/duckdb/src/execution/index/unknown_index.cpp +0 -65
- package/src/duckdb/src/execution/operator/csv_scanner/base_csv_reader.cpp +0 -595
- package/src/duckdb/src/execution/operator/csv_scanner/buffered_csv_reader.cpp +0 -434
- package/src/duckdb/src/execution/operator/csv_scanner/csv_buffer.cpp +0 -89
- package/src/duckdb/src/execution/operator/csv_scanner/csv_buffer_manager.cpp +0 -90
- package/src/duckdb/src/execution/operator/csv_scanner/csv_file_handle.cpp +0 -95
- package/src/duckdb/src/execution/operator/csv_scanner/csv_reader_options.cpp +0 -494
- package/src/duckdb/src/execution/operator/csv_scanner/csv_state_machine.cpp +0 -35
- package/src/duckdb/src/execution/operator/csv_scanner/csv_state_machine_cache.cpp +0 -99
- package/src/duckdb/src/execution/operator/csv_scanner/parallel_csv_reader.cpp +0 -689
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +0 -242
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +0 -695
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +0 -1487
- package/src/duckdb/src/execution/operator/persistent/csv_buffer.cpp +0 -72
- package/src/duckdb/src/execution/operator/persistent/csv_file_handle.cpp +0 -158
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +0 -280
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +0 -666
- package/src/duckdb/src/execution/operator/persistent/physical_fixed_batch_copy.cpp +0 -499
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +0 -207
- package/src/duckdb/src/execution/partitionable_hashtable.cpp +0 -207
- package/src/duckdb/src/execution/physical_plan/plan_limit_percent.cpp +0 -18
- package/src/duckdb/src/execution/physical_plan/plan_show_select.cpp +0 -47
- package/src/duckdb/src/execution/reservoir_sample.cpp +0 -324
- package/src/duckdb/src/execution/window_executor.cpp +0 -1830
- package/src/duckdb/src/execution/window_segment_tree.cpp +0 -2073
- package/src/duckdb/src/extension_forward_decl/icu.cpp +0 -59
- package/src/duckdb/src/function/aggregate/distributive_functions.cpp +0 -15
- package/src/duckdb/src/function/scalar/compressed_materialization_functions.cpp +0 -29
- package/src/duckdb/src/function/scalar/generic_functions.cpp +0 -11
- package/src/duckdb/src/function/scalar/list/list_concat.cpp +0 -143
- package/src/duckdb/src/function/scalar/operators.cpp +0 -14
- package/src/duckdb/src/function/scalar/sequence_functions.cpp +0 -10
- package/src/duckdb/src/function/scalar/string_functions.cpp +0 -22
- package/src/duckdb/src/function/table/pragma_detailed_profiling_output.cpp +0 -173
- package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +0 -101
- package/src/duckdb/src/include/duckdb/catalog/mapping_value.hpp +0 -92
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_types_extension.hpp +0 -42
- package/src/duckdb/src/include/duckdb/common/cycle_counter.hpp +0 -68
- package/src/duckdb/src/include/duckdb/common/enums/index_type.hpp +0 -34
- package/src/duckdb/src/include/duckdb/common/http_state.hpp +0 -113
- package/src/duckdb/src/include/duckdb/common/platform.h +0 -58
- package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +0 -59
- package/src/duckdb/src/include/duckdb/common/serializer/deserialization_data.hpp +0 -192
- package/src/duckdb/src/include/duckdb/common/types/chunk_collection.hpp +0 -137
- package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +0 -65
- package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +0 -63
- package/src/duckdb/src/include/duckdb/execution/index/unknown_index.hpp +0 -65
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/buffer_manager/csv_buffer.hpp +0 -103
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/buffer_manager/csv_buffer_manager.hpp +0 -74
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/buffer_manager/csv_file_handle.hpp +0 -60
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_sniffer.hpp +0 -253
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/options/csv_option.hpp +0 -155
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/options/csv_reader_options.hpp +0 -163
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/options/state_machine_options.hpp +0 -35
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner/base_scanner.hpp +0 -228
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner/column_count_scanner.hpp +0 -70
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner/scanner_boundary.hpp +0 -93
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner/skip_scanner.hpp +0 -60
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner/string_value_scanner.hpp +0 -197
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/sniffer/quote_rules.hpp +0 -21
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine/csv_state.hpp +0 -30
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine/csv_state_machine.hpp +0 -99
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.hpp +0 -87
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/table_function/csv_file_scanner.hpp +0 -70
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/table_function/global_csv_state.hpp +0 -80
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/util/csv_casting.hpp +0 -137
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/util/csv_error.hpp +0 -104
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +0 -79
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/base_csv_reader.hpp +0 -119
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/buffered_csv_reader.hpp +0 -72
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_buffer.hpp +0 -110
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_buffer_manager.hpp +0 -103
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_file_handle.hpp +0 -59
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_line_info.hpp +0 -46
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_reader_options.hpp +0 -210
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_sniffer.hpp +0 -131
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_state.hpp +0 -28
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_state_machine.hpp +0 -70
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_state_machine_cache.hpp +0 -65
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/parallel_csv_reader.hpp +0 -167
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/quote_rules.hpp +0 -21
- package/src/duckdb/src/include/duckdb/execution/window_executor.hpp +0 -343
- package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +0 -165
- package/src/duckdb/src/include/duckdb/optimizer/column_lifetime_optimizer.hpp +0 -45
- package/src/duckdb/src/include/duckdb/optimizer/join_order/estimated_properties.hpp +0 -57
- package/src/duckdb/src/include/duckdb/parser/parsed_data/comment_on_info.hpp +0 -45
- package/src/duckdb/src/include/duckdb/parser/statement/show_statement.hpp +0 -32
- package/src/duckdb/src/include/duckdb/planner/operator/logical_limit_percent.hpp +0 -49
- package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +0 -42
- package/src/duckdb/src/main/settings/settings.cpp +0 -2056
- package/src/duckdb/src/optimizer/join_order/estimated_properties.cpp +0 -36
- package/src/duckdb/src/parser/parsed_data/comment_on_info.cpp +0 -19
- package/src/duckdb/src/parser/statement/show_statement.cpp +0 -15
- package/src/duckdb/src/planner/binder/statement/bind_show.cpp +0 -30
- package/src/duckdb/src/planner/operator/logical_limit_percent.cpp +0 -14
- package/src/duckdb/src/storage/statistics/numeric_stats_union.cpp +0 -70
- package/src/duckdb/third_party/fsst/fsst_avx512.cpp +0 -140
- package/src/duckdb/third_party/fsst/fsst_avx512.inc +0 -57
- package/src/duckdb/third_party/fsst/fsst_avx512_unroll1.inc +0 -57
- package/src/duckdb/third_party/fsst/fsst_avx512_unroll2.inc +0 -114
- package/src/duckdb/third_party/fsst/fsst_avx512_unroll3.inc +0 -171
- package/src/duckdb/third_party/fsst/fsst_avx512_unroll4.inc +0 -228
- package/src/duckdb/third_party/parquet/parquet_constants.cpp +0 -17
- package/src/duckdb/third_party/parquet/parquet_constants.h +0 -24
- package/src/duckdb/third_party/re2/util/pod_array.h +0 -55
- package/src/duckdb/third_party/re2/util/sparse_array.h +0 -392
- package/src/duckdb/third_party/re2/util/sparse_set.h +0 -264
- package/src/duckdb/third_party/zstd/include/zstd/common/fse_static.h +0 -421
- package/src/duckdb/third_party/zstd/include/zstd/common/huf_static.h +0 -238
- package/src/duckdb/third_party/zstd/include/zstd_static.h +0 -1070
- package/src/duckdb/ub_src_core_functions.cpp +0 -6
- package/src/duckdb/ub_src_core_functions_aggregate_algebraic.cpp +0 -8
- package/src/duckdb/ub_src_core_functions_aggregate_distributive.cpp +0 -24
- package/src/duckdb/ub_src_core_functions_aggregate_holistic.cpp +0 -12
- package/src/duckdb/ub_src_core_functions_aggregate_nested.cpp +0 -6
- package/src/duckdb/ub_src_core_functions_aggregate_regression.cpp +0 -14
- package/src/duckdb/ub_src_core_functions_scalar_array.cpp +0 -4
- package/src/duckdb/ub_src_core_functions_scalar_bit.cpp +0 -2
- package/src/duckdb/ub_src_core_functions_scalar_blob.cpp +0 -6
- package/src/duckdb/ub_src_core_functions_scalar_date.cpp +0 -22
- package/src/duckdb/ub_src_core_functions_scalar_debug.cpp +0 -2
- package/src/duckdb/ub_src_core_functions_scalar_enum.cpp +0 -2
- package/src/duckdb/ub_src_core_functions_scalar_generic.cpp +0 -18
- package/src/duckdb/ub_src_core_functions_scalar_list.cpp +0 -22
- package/src/duckdb/ub_src_core_functions_scalar_map.cpp +0 -16
- package/src/duckdb/ub_src_core_functions_scalar_math.cpp +0 -2
- package/src/duckdb/ub_src_core_functions_scalar_operators.cpp +0 -2
- package/src/duckdb/ub_src_core_functions_scalar_random.cpp +0 -4
- package/src/duckdb/ub_src_core_functions_scalar_secret.cpp +0 -2
- package/src/duckdb/ub_src_core_functions_scalar_string.cpp +0 -58
- package/src/duckdb/ub_src_core_functions_scalar_struct.cpp +0 -4
- package/src/duckdb/ub_src_core_functions_scalar_union.cpp +0 -6
- package/src/duckdb/ub_src_execution_operator_csv_scanner.cpp +0 -18
- package/src/duckdb/ub_src_function_scalar_operators.cpp +0 -8
- /package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/algebraic/covar.hpp +0 -0
- /package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/algebraic/stddev.hpp +0 -0
- /package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/aggregate/sum_helpers.hpp +0 -0
- /package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/array_kernels.hpp +0 -0
- /package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/function_list.hpp +0 -0
- /package/src/duckdb/{src/include/duckdb → extension/core_functions/include}/core_functions/scalar/secret_functions.hpp +0 -0
- /package/src/duckdb/src/function/scalar/{operators → operator}/multiply.cpp +0 -0
- /package/src/duckdb/src/function/scalar/{operators → operator}/subtract.cpp +0 -0
@@ -1,2073 +0,0 @@
|
|
1
|
-
#include "duckdb/execution/window_segment_tree.hpp"
|
2
|
-
|
3
|
-
#include "duckdb/common/algorithm.hpp"
|
4
|
-
#include "duckdb/common/helper.hpp"
|
5
|
-
#include "duckdb/common/sort/partition_state.hpp"
|
6
|
-
#include "duckdb/common/vector_operations/vector_operations.hpp"
|
7
|
-
#include "duckdb/execution/merge_sort_tree.hpp"
|
8
|
-
#include "duckdb/planner/expression/bound_constant_expression.hpp"
|
9
|
-
#include "duckdb/execution/window_executor.hpp"
|
10
|
-
|
11
|
-
#include <numeric>
|
12
|
-
#include <thread>
|
13
|
-
#include <utility>
|
14
|
-
|
15
|
-
namespace duckdb {
|
16
|
-
|
17
|
-
//===--------------------------------------------------------------------===//
|
18
|
-
// WindowAggregator
|
19
|
-
//===--------------------------------------------------------------------===//
|
20
|
-
WindowAggregatorState::WindowAggregatorState() : allocator(Allocator::DefaultAllocator()) {
|
21
|
-
}
|
22
|
-
|
23
|
-
class WindowAggregatorGlobalState : public WindowAggregatorState {
|
24
|
-
public:
|
25
|
-
WindowAggregatorGlobalState(const WindowAggregator &aggregator_p, idx_t group_count)
|
26
|
-
: aggregator(aggregator_p), winputs(inputs), locals(0), finalized(0) {
|
27
|
-
|
28
|
-
if (!aggregator.arg_types.empty()) {
|
29
|
-
winputs.Initialize(Allocator::DefaultAllocator(), aggregator.arg_types, group_count);
|
30
|
-
}
|
31
|
-
if (aggregator.aggr.filter) {
|
32
|
-
// Start with all invalid and set the ones that pass
|
33
|
-
filter_mask.Initialize(group_count, false);
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
//! The aggregator data
|
38
|
-
const WindowAggregator &aggregator;
|
39
|
-
|
40
|
-
//! Partition data chunk
|
41
|
-
DataChunk inputs;
|
42
|
-
WindowDataChunk winputs;
|
43
|
-
|
44
|
-
//! The filtered rows in inputs.
|
45
|
-
ValidityArray filter_mask;
|
46
|
-
|
47
|
-
//! Lock for single threading
|
48
|
-
mutable mutex lock;
|
49
|
-
|
50
|
-
//! Count of local tasks
|
51
|
-
mutable std::atomic<idx_t> locals;
|
52
|
-
|
53
|
-
//! Number of finalised states
|
54
|
-
std::atomic<idx_t> finalized;
|
55
|
-
};
|
56
|
-
|
57
|
-
WindowAggregator::WindowAggregator(AggregateObject aggr_p, const vector<LogicalType> &arg_types_p,
|
58
|
-
const LogicalType &result_type_p, const WindowExcludeMode exclude_mode_p)
|
59
|
-
: aggr(std::move(aggr_p)), arg_types(arg_types_p), result_type(result_type_p),
|
60
|
-
state_size(aggr.function.state_size(aggr.function)), exclude_mode(exclude_mode_p) {
|
61
|
-
}
|
62
|
-
|
63
|
-
WindowAggregator::~WindowAggregator() {
|
64
|
-
}
|
65
|
-
|
66
|
-
unique_ptr<WindowAggregatorState> WindowAggregator::GetGlobalState(idx_t group_count, const ValidityMask &) const {
|
67
|
-
return make_uniq<WindowAggregatorGlobalState>(*this, group_count);
|
68
|
-
}
|
69
|
-
|
70
|
-
void WindowAggregator::Sink(WindowAggregatorState &gsink, WindowAggregatorState &lstate, DataChunk &arg_chunk,
|
71
|
-
idx_t input_idx, optional_ptr<SelectionVector> filter_sel, idx_t filtered) {
|
72
|
-
auto &gasink = gsink.Cast<WindowAggregatorGlobalState>();
|
73
|
-
auto &winputs = gasink.winputs;
|
74
|
-
auto &filter_mask = gasink.filter_mask;
|
75
|
-
if (winputs.chunk.ColumnCount()) {
|
76
|
-
winputs.Copy(arg_chunk, input_idx);
|
77
|
-
}
|
78
|
-
if (filter_sel) {
|
79
|
-
for (idx_t f = 0; f < filtered; ++f) {
|
80
|
-
filter_mask.SetValid(input_idx + filter_sel->get_index(f));
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
void WindowAggregator::Finalize(WindowAggregatorState &gstate, WindowAggregatorState &lstate, const FrameStats &stats) {
|
86
|
-
}
|
87
|
-
|
88
|
-
//===--------------------------------------------------------------------===//
|
89
|
-
// WindowConstantAggregator
|
90
|
-
//===--------------------------------------------------------------------===//
|
91
|
-
struct WindowAggregateStates {
|
92
|
-
explicit WindowAggregateStates(const AggregateObject &aggr);
|
93
|
-
~WindowAggregateStates() {
|
94
|
-
Destroy();
|
95
|
-
}
|
96
|
-
|
97
|
-
//! The number of states
|
98
|
-
idx_t GetCount() const {
|
99
|
-
return states.size() / state_size;
|
100
|
-
}
|
101
|
-
data_ptr_t *GetData() {
|
102
|
-
return FlatVector::GetData<data_ptr_t>(*statef);
|
103
|
-
}
|
104
|
-
data_ptr_t GetStatePtr(idx_t idx) {
|
105
|
-
return states.data() + idx * state_size;
|
106
|
-
}
|
107
|
-
const_data_ptr_t GetStatePtr(idx_t idx) const {
|
108
|
-
return states.data() + idx * state_size;
|
109
|
-
}
|
110
|
-
//! Initialise all the states
|
111
|
-
void Initialize(idx_t count);
|
112
|
-
//! Combine the states into the target
|
113
|
-
void Combine(WindowAggregateStates &target,
|
114
|
-
AggregateCombineType combine_type = AggregateCombineType::PRESERVE_INPUT);
|
115
|
-
//! Finalize the states into an output vector
|
116
|
-
void Finalize(Vector &result);
|
117
|
-
//! Destroy the states
|
118
|
-
void Destroy();
|
119
|
-
|
120
|
-
//! A description of the aggregator
|
121
|
-
const AggregateObject aggr;
|
122
|
-
//! The size of each state
|
123
|
-
const idx_t state_size;
|
124
|
-
//! The allocator to use
|
125
|
-
ArenaAllocator allocator;
|
126
|
-
//! Data pointer that contains the state data
|
127
|
-
vector<data_t> states;
|
128
|
-
//! Reused result state container for the window functions
|
129
|
-
unique_ptr<Vector> statef;
|
130
|
-
};
|
131
|
-
|
132
|
-
WindowAggregateStates::WindowAggregateStates(const AggregateObject &aggr)
|
133
|
-
: aggr(aggr), state_size(aggr.function.state_size(aggr.function)), allocator(Allocator::DefaultAllocator()) {
|
134
|
-
}
|
135
|
-
|
136
|
-
void WindowAggregateStates::Initialize(idx_t count) {
|
137
|
-
states.resize(count * state_size);
|
138
|
-
auto state_ptr = states.data();
|
139
|
-
|
140
|
-
statef = make_uniq<Vector>(LogicalType::POINTER, count);
|
141
|
-
auto state_f_data = FlatVector::GetData<data_ptr_t>(*statef);
|
142
|
-
|
143
|
-
for (idx_t i = 0; i < count; ++i, state_ptr += state_size) {
|
144
|
-
state_f_data[i] = state_ptr;
|
145
|
-
aggr.function.initialize(aggr.function, state_ptr);
|
146
|
-
}
|
147
|
-
|
148
|
-
// Prevent conversion of results to constants
|
149
|
-
statef->SetVectorType(VectorType::FLAT_VECTOR);
|
150
|
-
}
|
151
|
-
|
152
|
-
void WindowAggregateStates::Combine(WindowAggregateStates &target, AggregateCombineType combine_type) {
|
153
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator, AggregateCombineType::ALLOW_DESTRUCTIVE);
|
154
|
-
aggr.function.combine(*statef, *target.statef, aggr_input_data, GetCount());
|
155
|
-
}
|
156
|
-
|
157
|
-
void WindowAggregateStates::Finalize(Vector &result) {
|
158
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
159
|
-
aggr.function.finalize(*statef, aggr_input_data, result, GetCount(), 0);
|
160
|
-
}
|
161
|
-
|
162
|
-
void WindowAggregateStates::Destroy() {
|
163
|
-
if (states.empty()) {
|
164
|
-
return;
|
165
|
-
}
|
166
|
-
|
167
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
168
|
-
if (aggr.function.destructor) {
|
169
|
-
aggr.function.destructor(*statef, aggr_input_data, GetCount());
|
170
|
-
}
|
171
|
-
|
172
|
-
states.clear();
|
173
|
-
}
|
174
|
-
|
175
|
-
class WindowConstantAggregatorGlobalState : public WindowAggregatorGlobalState {
|
176
|
-
public:
|
177
|
-
WindowConstantAggregatorGlobalState(const WindowConstantAggregator &aggregator, idx_t count,
|
178
|
-
const ValidityMask &partition_mask);
|
179
|
-
|
180
|
-
void Finalize(const FrameStats &stats);
|
181
|
-
|
182
|
-
//! Partition starts
|
183
|
-
vector<idx_t> partition_offsets;
|
184
|
-
//! Reused result state container for the window functions
|
185
|
-
WindowAggregateStates statef;
|
186
|
-
//! Aggregate results
|
187
|
-
unique_ptr<Vector> results;
|
188
|
-
};
|
189
|
-
|
190
|
-
class WindowConstantAggregatorLocalState : public WindowAggregatorState {
|
191
|
-
public:
|
192
|
-
explicit WindowConstantAggregatorLocalState(const WindowConstantAggregatorGlobalState &gstate);
|
193
|
-
~WindowConstantAggregatorLocalState() override {
|
194
|
-
}
|
195
|
-
|
196
|
-
void Sink(DataChunk &payload_chunk, idx_t input_idx, optional_ptr<SelectionVector> filter_sel, idx_t filtered);
|
197
|
-
void Combine(WindowConstantAggregatorGlobalState &gstate);
|
198
|
-
|
199
|
-
public:
|
200
|
-
//! The global state we are sharing
|
201
|
-
const WindowConstantAggregatorGlobalState &gstate;
|
202
|
-
//! Reusable chunk for sinking
|
203
|
-
DataChunk inputs;
|
204
|
-
//! A vector of pointers to "state", used for intermediate window segment aggregation
|
205
|
-
Vector statep;
|
206
|
-
//! Reused result state container for the window functions
|
207
|
-
WindowAggregateStates statef;
|
208
|
-
//! The current result partition being read
|
209
|
-
idx_t partition;
|
210
|
-
//! Shared SV for evaluation
|
211
|
-
SelectionVector matches;
|
212
|
-
};
|
213
|
-
|
214
|
-
WindowConstantAggregatorGlobalState::WindowConstantAggregatorGlobalState(const WindowConstantAggregator &aggregator,
|
215
|
-
idx_t group_count,
|
216
|
-
const ValidityMask &partition_mask)
|
217
|
-
: WindowAggregatorGlobalState(aggregator, STANDARD_VECTOR_SIZE), statef(aggregator.aggr) {
|
218
|
-
|
219
|
-
// Locate the partition boundaries
|
220
|
-
if (partition_mask.AllValid()) {
|
221
|
-
partition_offsets.emplace_back(0);
|
222
|
-
} else {
|
223
|
-
idx_t entry_idx;
|
224
|
-
idx_t shift;
|
225
|
-
for (idx_t start = 0; start < group_count;) {
|
226
|
-
partition_mask.GetEntryIndex(start, entry_idx, shift);
|
227
|
-
|
228
|
-
// If start is aligned with the start of a block,
|
229
|
-
// and the block is blank, then skip forward one block.
|
230
|
-
const auto block = partition_mask.GetValidityEntry(entry_idx);
|
231
|
-
if (partition_mask.NoneValid(block) && !shift) {
|
232
|
-
start += ValidityMask::BITS_PER_VALUE;
|
233
|
-
continue;
|
234
|
-
}
|
235
|
-
|
236
|
-
// Loop over the block
|
237
|
-
for (; shift < ValidityMask::BITS_PER_VALUE && start < group_count; ++shift, ++start) {
|
238
|
-
if (partition_mask.RowIsValid(block, shift)) {
|
239
|
-
partition_offsets.emplace_back(start);
|
240
|
-
}
|
241
|
-
}
|
242
|
-
}
|
243
|
-
}
|
244
|
-
|
245
|
-
// Initialise the vector for caching the results
|
246
|
-
results = make_uniq<Vector>(aggregator.result_type, partition_offsets.size());
|
247
|
-
|
248
|
-
// Initialise the final states
|
249
|
-
statef.Initialize(partition_offsets.size());
|
250
|
-
|
251
|
-
// Add final guard
|
252
|
-
partition_offsets.emplace_back(group_count);
|
253
|
-
}
|
254
|
-
|
255
|
-
WindowConstantAggregatorLocalState::WindowConstantAggregatorLocalState(
|
256
|
-
const WindowConstantAggregatorGlobalState &gstate)
|
257
|
-
: gstate(gstate), statep(Value::POINTER(0)), statef(gstate.statef.aggr), partition(0) {
|
258
|
-
matches.Initialize();
|
259
|
-
|
260
|
-
// Start the aggregates
|
261
|
-
auto &partition_offsets = gstate.partition_offsets;
|
262
|
-
auto &aggregator = gstate.aggregator;
|
263
|
-
statef.Initialize(partition_offsets.size() - 1);
|
264
|
-
|
265
|
-
// Set up shared buffer
|
266
|
-
inputs.Initialize(Allocator::DefaultAllocator(), aggregator.arg_types);
|
267
|
-
|
268
|
-
gstate.locals++;
|
269
|
-
}
|
270
|
-
|
271
|
-
WindowConstantAggregator::WindowConstantAggregator(AggregateObject aggr, const vector<LogicalType> &arg_types,
|
272
|
-
const LogicalType &result_type,
|
273
|
-
const WindowExcludeMode exclude_mode_p)
|
274
|
-
: WindowAggregator(std::move(aggr), arg_types, result_type, exclude_mode_p) {
|
275
|
-
}
|
276
|
-
|
277
|
-
unique_ptr<WindowAggregatorState> WindowConstantAggregator::GetGlobalState(idx_t group_count,
|
278
|
-
const ValidityMask &partition_mask) const {
|
279
|
-
return make_uniq<WindowConstantAggregatorGlobalState>(*this, group_count, partition_mask);
|
280
|
-
}
|
281
|
-
|
282
|
-
void WindowConstantAggregator::Sink(WindowAggregatorState &gsink, WindowAggregatorState &lstate, DataChunk &arg_chunk,
|
283
|
-
idx_t input_idx, optional_ptr<SelectionVector> filter_sel, idx_t filtered) {
|
284
|
-
auto &lastate = lstate.Cast<WindowConstantAggregatorLocalState>();
|
285
|
-
|
286
|
-
lastate.Sink(arg_chunk, input_idx, filter_sel, filtered);
|
287
|
-
}
|
288
|
-
|
289
|
-
void WindowConstantAggregatorLocalState::Sink(DataChunk &payload_chunk, idx_t row,
|
290
|
-
optional_ptr<SelectionVector> filter_sel, idx_t filtered) {
|
291
|
-
auto &partition_offsets = gstate.partition_offsets;
|
292
|
-
auto &aggregator = gstate.aggregator;
|
293
|
-
const auto &aggr = aggregator.aggr;
|
294
|
-
const auto chunk_begin = row;
|
295
|
-
const auto chunk_end = chunk_begin + payload_chunk.size();
|
296
|
-
idx_t partition =
|
297
|
-
idx_t(std::upper_bound(partition_offsets.begin(), partition_offsets.end(), row) - partition_offsets.begin()) -
|
298
|
-
1;
|
299
|
-
|
300
|
-
auto state_f_data = statef.GetData();
|
301
|
-
auto state_p_data = FlatVector::GetData<data_ptr_t>(statep);
|
302
|
-
|
303
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
304
|
-
idx_t begin = 0;
|
305
|
-
idx_t filter_idx = 0;
|
306
|
-
auto partition_end = partition_offsets[partition + 1];
|
307
|
-
while (row < chunk_end) {
|
308
|
-
if (row == partition_end) {
|
309
|
-
++partition;
|
310
|
-
partition_end = partition_offsets[partition + 1];
|
311
|
-
}
|
312
|
-
partition_end = MinValue(partition_end, chunk_end);
|
313
|
-
auto end = partition_end - chunk_begin;
|
314
|
-
|
315
|
-
inputs.Reset();
|
316
|
-
if (filter_sel) {
|
317
|
-
// Slice to any filtered rows in [begin, end)
|
318
|
-
SelectionVector sel;
|
319
|
-
|
320
|
-
// Find the first value in [begin, end)
|
321
|
-
for (; filter_idx < filtered; ++filter_idx) {
|
322
|
-
auto idx = filter_sel->get_index(filter_idx);
|
323
|
-
if (idx >= begin) {
|
324
|
-
break;
|
325
|
-
}
|
326
|
-
}
|
327
|
-
|
328
|
-
// Find the first value in [end, filtered)
|
329
|
-
sel.Initialize(filter_sel->data() + filter_idx);
|
330
|
-
idx_t nsel = 0;
|
331
|
-
for (; filter_idx < filtered; ++filter_idx, ++nsel) {
|
332
|
-
auto idx = filter_sel->get_index(filter_idx);
|
333
|
-
if (idx >= end) {
|
334
|
-
break;
|
335
|
-
}
|
336
|
-
}
|
337
|
-
|
338
|
-
if (nsel != inputs.size()) {
|
339
|
-
inputs.Slice(payload_chunk, sel, nsel);
|
340
|
-
}
|
341
|
-
} else {
|
342
|
-
// Slice to [begin, end)
|
343
|
-
if (begin) {
|
344
|
-
for (idx_t c = 0; c < payload_chunk.ColumnCount(); ++c) {
|
345
|
-
inputs.data[c].Slice(payload_chunk.data[c], begin, end);
|
346
|
-
}
|
347
|
-
} else {
|
348
|
-
inputs.Reference(payload_chunk);
|
349
|
-
}
|
350
|
-
inputs.SetCardinality(end - begin);
|
351
|
-
}
|
352
|
-
|
353
|
-
// Aggregate the filtered rows into a single state
|
354
|
-
const auto count = inputs.size();
|
355
|
-
auto state = state_f_data[partition];
|
356
|
-
if (aggr.function.simple_update) {
|
357
|
-
aggr.function.simple_update(inputs.data.data(), aggr_input_data, inputs.ColumnCount(), state, count);
|
358
|
-
} else {
|
359
|
-
state_p_data[0] = state_f_data[partition];
|
360
|
-
aggr.function.update(inputs.data.data(), aggr_input_data, inputs.ColumnCount(), statep, count);
|
361
|
-
}
|
362
|
-
|
363
|
-
// Skip filtered rows too!
|
364
|
-
row += end - begin;
|
365
|
-
begin = end;
|
366
|
-
}
|
367
|
-
}
|
368
|
-
|
369
|
-
void WindowConstantAggregator::Finalize(WindowAggregatorState &gstate, WindowAggregatorState &lstate,
|
370
|
-
const FrameStats &stats) {
|
371
|
-
auto &gastate = gstate.Cast<WindowConstantAggregatorGlobalState>();
|
372
|
-
auto &lastate = lstate.Cast<WindowConstantAggregatorLocalState>();
|
373
|
-
|
374
|
-
// Single-threaded combine
|
375
|
-
lock_guard<mutex> finalize_guard(gastate.lock);
|
376
|
-
lastate.statef.Combine(gastate.statef);
|
377
|
-
lastate.statef.Destroy();
|
378
|
-
|
379
|
-
// Last one out turns off the lights!
|
380
|
-
if (++gastate.finalized == gastate.locals) {
|
381
|
-
gastate.statef.Finalize(*gastate.results);
|
382
|
-
gastate.statef.Destroy();
|
383
|
-
}
|
384
|
-
}
|
385
|
-
|
386
|
-
unique_ptr<WindowAggregatorState> WindowConstantAggregator::GetLocalState(const WindowAggregatorState &gstate) const {
|
387
|
-
return make_uniq<WindowConstantAggregatorLocalState>(gstate.Cast<WindowConstantAggregatorGlobalState>());
|
388
|
-
}
|
389
|
-
|
390
|
-
void WindowConstantAggregator::Evaluate(const WindowAggregatorState &gsink, WindowAggregatorState &lstate,
|
391
|
-
const DataChunk &bounds, Vector &result, idx_t count, idx_t row_idx) const {
|
392
|
-
auto &gasink = gsink.Cast<WindowConstantAggregatorGlobalState>();
|
393
|
-
const auto &partition_offsets = gasink.partition_offsets;
|
394
|
-
const auto &results = *gasink.results;
|
395
|
-
|
396
|
-
auto begins = FlatVector::GetData<const idx_t>(bounds.data[WINDOW_BEGIN]);
|
397
|
-
// Chunk up the constants and copy them one at a time
|
398
|
-
auto &lcstate = lstate.Cast<WindowConstantAggregatorLocalState>();
|
399
|
-
idx_t matched = 0;
|
400
|
-
idx_t target_offset = 0;
|
401
|
-
for (idx_t i = 0; i < count; ++i) {
|
402
|
-
const auto begin = begins[i];
|
403
|
-
// Find the partition containing [begin, end)
|
404
|
-
while (partition_offsets[lcstate.partition + 1] <= begin) {
|
405
|
-
// Flush the previous partition's data
|
406
|
-
if (matched) {
|
407
|
-
VectorOperations::Copy(results, result, lcstate.matches, matched, 0, target_offset);
|
408
|
-
target_offset += matched;
|
409
|
-
matched = 0;
|
410
|
-
}
|
411
|
-
++lcstate.partition;
|
412
|
-
}
|
413
|
-
|
414
|
-
lcstate.matches.set_index(matched++, lcstate.partition);
|
415
|
-
}
|
416
|
-
|
417
|
-
// Flush the last partition
|
418
|
-
if (matched) {
|
419
|
-
// Optimize constant result
|
420
|
-
if (target_offset == 0 && matched == count) {
|
421
|
-
VectorOperations::Copy(results, result, lcstate.matches, 1, 0, target_offset);
|
422
|
-
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
423
|
-
} else {
|
424
|
-
VectorOperations::Copy(results, result, lcstate.matches, matched, 0, target_offset);
|
425
|
-
}
|
426
|
-
}
|
427
|
-
}
|
428
|
-
|
429
|
-
//===--------------------------------------------------------------------===//
|
430
|
-
// WindowCustomAggregator
|
431
|
-
//===--------------------------------------------------------------------===//
|
432
|
-
WindowCustomAggregator::WindowCustomAggregator(AggregateObject aggr, const vector<LogicalType> &arg_types,
|
433
|
-
const LogicalType &result_type, const WindowExcludeMode exclude_mode)
|
434
|
-
: WindowAggregator(std::move(aggr), arg_types, result_type, exclude_mode) {
|
435
|
-
}
|
436
|
-
|
437
|
-
WindowCustomAggregator::~WindowCustomAggregator() {
|
438
|
-
}
|
439
|
-
|
440
|
-
class WindowCustomAggregatorState : public WindowAggregatorState {
|
441
|
-
public:
|
442
|
-
WindowCustomAggregatorState(const AggregateObject &aggr, const WindowExcludeMode exclude_mode);
|
443
|
-
~WindowCustomAggregatorState() override;
|
444
|
-
|
445
|
-
public:
|
446
|
-
//! The aggregate function
|
447
|
-
const AggregateObject &aggr;
|
448
|
-
//! Data pointer that contains a single state, shared by all the custom evaluators
|
449
|
-
vector<data_t> state;
|
450
|
-
//! Reused result state container for the window functions
|
451
|
-
Vector statef;
|
452
|
-
//! The frame boundaries, used for the window functions
|
453
|
-
SubFrames frames;
|
454
|
-
};
|
455
|
-
|
456
|
-
static void InitSubFrames(SubFrames &frames, const WindowExcludeMode exclude_mode) {
|
457
|
-
idx_t nframes = 0;
|
458
|
-
switch (exclude_mode) {
|
459
|
-
case WindowExcludeMode::NO_OTHER:
|
460
|
-
nframes = 1;
|
461
|
-
break;
|
462
|
-
case WindowExcludeMode::TIES:
|
463
|
-
nframes = 3;
|
464
|
-
break;
|
465
|
-
case WindowExcludeMode::CURRENT_ROW:
|
466
|
-
case WindowExcludeMode::GROUP:
|
467
|
-
nframes = 2;
|
468
|
-
break;
|
469
|
-
}
|
470
|
-
frames.resize(nframes, {0, 0});
|
471
|
-
}
|
472
|
-
|
473
|
-
class WindowCustomAggregatorGlobalState : public WindowAggregatorGlobalState {
|
474
|
-
public:
|
475
|
-
explicit WindowCustomAggregatorGlobalState(const WindowCustomAggregator &aggregator, idx_t group_count)
|
476
|
-
: WindowAggregatorGlobalState(aggregator, group_count) {
|
477
|
-
|
478
|
-
gcstate = make_uniq<WindowCustomAggregatorState>(aggregator.aggr, aggregator.exclude_mode);
|
479
|
-
}
|
480
|
-
|
481
|
-
//! Traditional packed filter mask for API
|
482
|
-
ValidityMask filter_packed;
|
483
|
-
//! Data pointer that contains a single local state, used for global custom window execution state
|
484
|
-
unique_ptr<WindowCustomAggregatorState> gcstate;
|
485
|
-
//! Partition description for custom window APIs
|
486
|
-
unique_ptr<WindowPartitionInput> partition_input;
|
487
|
-
};
|
488
|
-
|
489
|
-
WindowCustomAggregatorState::WindowCustomAggregatorState(const AggregateObject &aggr,
|
490
|
-
const WindowExcludeMode exclude_mode)
|
491
|
-
: aggr(aggr), state(aggr.function.state_size(aggr.function)),
|
492
|
-
statef(Value::POINTER(CastPointerToValue(state.data()))), frames(3, {0, 0}) {
|
493
|
-
// if we have a frame-by-frame method, share the single state
|
494
|
-
aggr.function.initialize(aggr.function, state.data());
|
495
|
-
|
496
|
-
InitSubFrames(frames, exclude_mode);
|
497
|
-
}
|
498
|
-
|
499
|
-
WindowCustomAggregatorState::~WindowCustomAggregatorState() {
|
500
|
-
if (aggr.function.destructor) {
|
501
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
502
|
-
aggr.function.destructor(statef, aggr_input_data, 1);
|
503
|
-
}
|
504
|
-
}
|
505
|
-
|
506
|
-
unique_ptr<WindowAggregatorState> WindowCustomAggregator::GetGlobalState(idx_t group_count,
|
507
|
-
const ValidityMask &) const {
|
508
|
-
return make_uniq<WindowCustomAggregatorGlobalState>(*this, group_count);
|
509
|
-
}
|
510
|
-
|
511
|
-
void WindowCustomAggregator::Finalize(WindowAggregatorState &gsink, WindowAggregatorState &lstate,
|
512
|
-
const FrameStats &stats) {
|
513
|
-
// Single threaded Finalize for now
|
514
|
-
auto &gcsink = gsink.Cast<WindowCustomAggregatorGlobalState>();
|
515
|
-
lock_guard<mutex> gestate_guard(gcsink.lock);
|
516
|
-
if (gcsink.finalized) {
|
517
|
-
return;
|
518
|
-
}
|
519
|
-
|
520
|
-
WindowAggregator::Finalize(gsink, lstate, stats);
|
521
|
-
|
522
|
-
auto &inputs = gcsink.inputs;
|
523
|
-
auto &filter_mask = gcsink.filter_mask;
|
524
|
-
auto &filter_packed = gcsink.filter_packed;
|
525
|
-
filter_mask.Pack(filter_packed, filter_mask.target_count);
|
526
|
-
|
527
|
-
gcsink.partition_input =
|
528
|
-
make_uniq<WindowPartitionInput>(inputs.data.data(), inputs.ColumnCount(), inputs.size(), filter_packed, stats);
|
529
|
-
|
530
|
-
if (aggr.function.window_init) {
|
531
|
-
auto &gcstate = *gcsink.gcstate;
|
532
|
-
|
533
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), gcstate.allocator);
|
534
|
-
aggr.function.window_init(aggr_input_data, *gcsink.partition_input, gcstate.state.data());
|
535
|
-
}
|
536
|
-
|
537
|
-
++gcsink.finalized;
|
538
|
-
}
|
539
|
-
|
540
|
-
unique_ptr<WindowAggregatorState> WindowCustomAggregator::GetLocalState(const WindowAggregatorState &gstate) const {
|
541
|
-
return make_uniq<WindowCustomAggregatorState>(aggr, exclude_mode);
|
542
|
-
}
|
543
|
-
|
544
|
-
template <typename OP>
|
545
|
-
static void EvaluateSubFrames(const DataChunk &bounds, const WindowExcludeMode exclude_mode, idx_t count, idx_t row_idx,
|
546
|
-
SubFrames &frames, OP operation) {
|
547
|
-
auto begins = FlatVector::GetData<const idx_t>(bounds.data[WINDOW_BEGIN]);
|
548
|
-
auto ends = FlatVector::GetData<const idx_t>(bounds.data[WINDOW_END]);
|
549
|
-
auto peer_begin = FlatVector::GetData<const idx_t>(bounds.data[PEER_BEGIN]);
|
550
|
-
auto peer_end = FlatVector::GetData<const idx_t>(bounds.data[PEER_END]);
|
551
|
-
|
552
|
-
for (idx_t i = 0, cur_row = row_idx; i < count; ++i, ++cur_row) {
|
553
|
-
idx_t nframes = 0;
|
554
|
-
if (exclude_mode == WindowExcludeMode::NO_OTHER) {
|
555
|
-
auto begin = begins[i];
|
556
|
-
auto end = ends[i];
|
557
|
-
frames[nframes++] = FrameBounds(begin, end);
|
558
|
-
} else {
|
559
|
-
// The frame_exclusion option allows rows around the current row to be excluded from the frame,
|
560
|
-
// even if they would be included according to the frame start and frame end options.
|
561
|
-
// EXCLUDE CURRENT ROW excludes the current row from the frame.
|
562
|
-
// EXCLUDE GROUP excludes the current row and its ordering peers from the frame.
|
563
|
-
// EXCLUDE TIES excludes any peers of the current row from the frame, but not the current row itself.
|
564
|
-
// EXCLUDE NO OTHERS simply specifies explicitly the default behavior
|
565
|
-
// of not excluding the current row or its peers.
|
566
|
-
// https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS
|
567
|
-
//
|
568
|
-
// For the sake of the client, we make some guarantees about the subframes:
|
569
|
-
// * They are in order left-to-right
|
570
|
-
// * They do not intersect
|
571
|
-
// * start <= end
|
572
|
-
// * The number is always the same
|
573
|
-
//
|
574
|
-
// Since we always have peer_begin <= cur_row < cur_row + 1 <= peer_end
|
575
|
-
// this is not too hard to arrange, but it may be that some subframes are contiguous,
|
576
|
-
// and some are empty.
|
577
|
-
|
578
|
-
// WindowExcludePart::LEFT
|
579
|
-
auto begin = begins[i];
|
580
|
-
auto end = (exclude_mode == WindowExcludeMode::CURRENT_ROW) ? cur_row : peer_begin[i];
|
581
|
-
end = MaxValue(begin, end);
|
582
|
-
frames[nframes++] = FrameBounds(begin, end);
|
583
|
-
|
584
|
-
// with EXCLUDE TIES, in addition to the frame part right of the peer group's end,
|
585
|
-
// we also need to consider the current row
|
586
|
-
if (exclude_mode == WindowExcludeMode::TIES) {
|
587
|
-
frames[nframes++] = FrameBounds(cur_row, cur_row + 1);
|
588
|
-
}
|
589
|
-
|
590
|
-
// WindowExcludePart::RIGHT
|
591
|
-
end = ends[i];
|
592
|
-
begin = (exclude_mode == WindowExcludeMode::CURRENT_ROW) ? (cur_row + 1) : peer_end[i];
|
593
|
-
begin = MinValue(begin, end);
|
594
|
-
frames[nframes++] = FrameBounds(begin, end);
|
595
|
-
}
|
596
|
-
|
597
|
-
operation(i);
|
598
|
-
}
|
599
|
-
}
|
600
|
-
|
601
|
-
void WindowCustomAggregator::Evaluate(const WindowAggregatorState &gsink, WindowAggregatorState &lstate,
|
602
|
-
const DataChunk &bounds, Vector &result, idx_t count, idx_t row_idx) const {
|
603
|
-
auto &lcstate = lstate.Cast<WindowCustomAggregatorState>();
|
604
|
-
auto &frames = lcstate.frames;
|
605
|
-
const_data_ptr_t gstate_p = nullptr;
|
606
|
-
auto &gcsink = gsink.Cast<WindowCustomAggregatorGlobalState>();
|
607
|
-
if (gcsink.gcstate) {
|
608
|
-
gstate_p = gcsink.gcstate->state.data();
|
609
|
-
}
|
610
|
-
|
611
|
-
EvaluateSubFrames(bounds, exclude_mode, count, row_idx, frames, [&](idx_t i) {
|
612
|
-
// Extract the range
|
613
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), lstate.allocator);
|
614
|
-
aggr.function.window(aggr_input_data, *gcsink.partition_input, gstate_p, lcstate.state.data(), frames, result,
|
615
|
-
i);
|
616
|
-
});
|
617
|
-
}
|
618
|
-
|
619
|
-
//===--------------------------------------------------------------------===//
|
620
|
-
// WindowNaiveAggregator
|
621
|
-
//===--------------------------------------------------------------------===//
|
622
|
-
WindowNaiveAggregator::WindowNaiveAggregator(AggregateObject aggr, const vector<LogicalType> &arg_types,
|
623
|
-
const LogicalType &result_type, const WindowExcludeMode exclude_mode)
|
624
|
-
: WindowAggregator(std::move(aggr), arg_types, result_type, exclude_mode) {
|
625
|
-
}
|
626
|
-
|
627
|
-
WindowNaiveAggregator::~WindowNaiveAggregator() {
|
628
|
-
}
|
629
|
-
|
630
|
-
class WindowNaiveState : public WindowAggregatorState {
|
631
|
-
public:
|
632
|
-
struct HashRow {
|
633
|
-
HashRow(WindowNaiveState &state, const DataChunk &inputs) : state(state), inputs(inputs) {
|
634
|
-
}
|
635
|
-
|
636
|
-
size_t operator()(const idx_t &i) const {
|
637
|
-
return state.Hash(inputs, i);
|
638
|
-
}
|
639
|
-
|
640
|
-
WindowNaiveState &state;
|
641
|
-
const DataChunk &inputs;
|
642
|
-
};
|
643
|
-
|
644
|
-
struct EqualRow {
|
645
|
-
EqualRow(WindowNaiveState &state, const DataChunk &inputs) : state(state), inputs(inputs) {
|
646
|
-
}
|
647
|
-
|
648
|
-
bool operator()(const idx_t &lhs, const idx_t &rhs) const {
|
649
|
-
return state.KeyEqual(inputs, lhs, rhs);
|
650
|
-
}
|
651
|
-
|
652
|
-
WindowNaiveState &state;
|
653
|
-
const DataChunk &inputs;
|
654
|
-
};
|
655
|
-
|
656
|
-
using RowSet = std::unordered_set<idx_t, HashRow, EqualRow>;
|
657
|
-
|
658
|
-
explicit WindowNaiveState(const WindowNaiveAggregator &gsink);
|
659
|
-
|
660
|
-
void Evaluate(const WindowAggregatorGlobalState &gsink, const DataChunk &bounds, Vector &result, idx_t count,
|
661
|
-
idx_t row_idx);
|
662
|
-
|
663
|
-
protected:
|
664
|
-
//! Flush the accumulated intermediate states into the result states
|
665
|
-
void FlushStates(const WindowAggregatorGlobalState &gsink);
|
666
|
-
|
667
|
-
//! Hashes a value for the hash table
|
668
|
-
size_t Hash(const DataChunk &inputs, idx_t rid);
|
669
|
-
//! Compares two values for the hash table
|
670
|
-
bool KeyEqual(const DataChunk &inputs, const idx_t &lhs, const idx_t &rhs);
|
671
|
-
|
672
|
-
//! The global state
|
673
|
-
const WindowNaiveAggregator &aggregator;
|
674
|
-
//! Data pointer that contains a vector of states, used for row aggregation
|
675
|
-
vector<data_t> state;
|
676
|
-
//! Reused result state container for the aggregate
|
677
|
-
Vector statef;
|
678
|
-
//! A vector of pointers to "state", used for buffering intermediate aggregates
|
679
|
-
Vector statep;
|
680
|
-
//! Input data chunk, used for leaf segment aggregation
|
681
|
-
DataChunk leaves;
|
682
|
-
//! The rows beging updated.
|
683
|
-
SelectionVector update_sel;
|
684
|
-
//! Count of buffered values
|
685
|
-
idx_t flush_count;
|
686
|
-
//! The frame boundaries, used for EXCLUDE
|
687
|
-
SubFrames frames;
|
688
|
-
//! The optional hash table used for DISTINCT
|
689
|
-
Vector hashes;
|
690
|
-
};
|
691
|
-
|
692
|
-
WindowNaiveState::WindowNaiveState(const WindowNaiveAggregator &aggregator_p)
|
693
|
-
: aggregator(aggregator_p), state(aggregator.state_size * STANDARD_VECTOR_SIZE), statef(LogicalType::POINTER),
|
694
|
-
statep((LogicalType::POINTER)), flush_count(0), hashes(LogicalType::HASH) {
|
695
|
-
InitSubFrames(frames, aggregator.exclude_mode);
|
696
|
-
|
697
|
-
update_sel.Initialize();
|
698
|
-
|
699
|
-
// Build the finalise vector that just points to the result states
|
700
|
-
data_ptr_t state_ptr = state.data();
|
701
|
-
D_ASSERT(statef.GetVectorType() == VectorType::FLAT_VECTOR);
|
702
|
-
statef.SetVectorType(VectorType::CONSTANT_VECTOR);
|
703
|
-
statef.Flatten(STANDARD_VECTOR_SIZE);
|
704
|
-
auto fdata = FlatVector::GetData<data_ptr_t>(statef);
|
705
|
-
for (idx_t i = 0; i < STANDARD_VECTOR_SIZE; ++i) {
|
706
|
-
fdata[i] = state_ptr;
|
707
|
-
state_ptr += aggregator.state_size;
|
708
|
-
}
|
709
|
-
}
|
710
|
-
|
711
|
-
void WindowNaiveState::FlushStates(const WindowAggregatorGlobalState &gsink) {
|
712
|
-
if (!flush_count) {
|
713
|
-
return;
|
714
|
-
}
|
715
|
-
|
716
|
-
auto &inputs = gsink.inputs;
|
717
|
-
leaves.Slice(inputs, update_sel, flush_count);
|
718
|
-
|
719
|
-
auto &aggr = aggregator.aggr;
|
720
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
721
|
-
aggr.function.update(leaves.data.data(), aggr_input_data, leaves.ColumnCount(), statep, flush_count);
|
722
|
-
|
723
|
-
flush_count = 0;
|
724
|
-
}
|
725
|
-
|
726
|
-
size_t WindowNaiveState::Hash(const DataChunk &inputs, idx_t rid) {
|
727
|
-
auto s = UnsafeNumericCast<sel_t>(rid);
|
728
|
-
SelectionVector sel(&s);
|
729
|
-
leaves.Slice(inputs, sel, 1);
|
730
|
-
leaves.Hash(hashes);
|
731
|
-
|
732
|
-
return *FlatVector::GetData<hash_t>(hashes);
|
733
|
-
}
|
734
|
-
|
735
|
-
bool WindowNaiveState::KeyEqual(const DataChunk &inputs, const idx_t &lhs, const idx_t &rhs) {
|
736
|
-
auto l = UnsafeNumericCast<sel_t>(lhs);
|
737
|
-
SelectionVector lsel(&l);
|
738
|
-
|
739
|
-
auto r = UnsafeNumericCast<sel_t>(rhs);
|
740
|
-
SelectionVector rsel(&r);
|
741
|
-
|
742
|
-
sel_t f = 0;
|
743
|
-
SelectionVector fsel(&f);
|
744
|
-
|
745
|
-
for (auto &input : inputs.data) {
|
746
|
-
Vector left(input, lsel, 1);
|
747
|
-
Vector right(input, rsel, 1);
|
748
|
-
if (!VectorOperations::NotDistinctFrom(left, right, nullptr, 1, nullptr, &fsel)) {
|
749
|
-
return false;
|
750
|
-
}
|
751
|
-
}
|
752
|
-
|
753
|
-
return true;
|
754
|
-
}
|
755
|
-
|
756
|
-
void WindowNaiveState::Evaluate(const WindowAggregatorGlobalState &gsink, const DataChunk &bounds, Vector &result,
|
757
|
-
idx_t count, idx_t row_idx) {
|
758
|
-
auto &aggr = aggregator.aggr;
|
759
|
-
auto &filter_mask = gsink.filter_mask;
|
760
|
-
auto &inputs = gsink.inputs;
|
761
|
-
|
762
|
-
if (leaves.ColumnCount() == 0 && inputs.ColumnCount() > 0) {
|
763
|
-
leaves.Initialize(Allocator::DefaultAllocator(), inputs.GetTypes());
|
764
|
-
}
|
765
|
-
|
766
|
-
auto fdata = FlatVector::GetData<data_ptr_t>(statef);
|
767
|
-
auto pdata = FlatVector::GetData<data_ptr_t>(statep);
|
768
|
-
|
769
|
-
HashRow hash_row(*this, inputs);
|
770
|
-
EqualRow equal_row(*this, inputs);
|
771
|
-
RowSet row_set(STANDARD_VECTOR_SIZE, hash_row, equal_row);
|
772
|
-
|
773
|
-
EvaluateSubFrames(bounds, aggregator.exclude_mode, count, row_idx, frames, [&](idx_t rid) {
|
774
|
-
auto agg_state = fdata[rid];
|
775
|
-
aggr.function.initialize(aggr.function, agg_state);
|
776
|
-
|
777
|
-
// Just update the aggregate with the unfiltered input rows
|
778
|
-
row_set.clear();
|
779
|
-
for (const auto &frame : frames) {
|
780
|
-
for (auto f = frame.start; f < frame.end; ++f) {
|
781
|
-
if (!filter_mask.RowIsValid(f)) {
|
782
|
-
continue;
|
783
|
-
}
|
784
|
-
|
785
|
-
// Filter out duplicates
|
786
|
-
if (aggr.IsDistinct() && !row_set.insert(f).second) {
|
787
|
-
continue;
|
788
|
-
}
|
789
|
-
|
790
|
-
pdata[flush_count] = agg_state;
|
791
|
-
update_sel[flush_count++] = UnsafeNumericCast<sel_t>(f);
|
792
|
-
if (flush_count >= STANDARD_VECTOR_SIZE) {
|
793
|
-
FlushStates(gsink);
|
794
|
-
}
|
795
|
-
}
|
796
|
-
}
|
797
|
-
});
|
798
|
-
|
799
|
-
// Flush the final states
|
800
|
-
FlushStates(gsink);
|
801
|
-
|
802
|
-
// Finalise the result aggregates and write to the result
|
803
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
804
|
-
aggr.function.finalize(statef, aggr_input_data, result, count, 0);
|
805
|
-
|
806
|
-
// Destruct the result aggregates
|
807
|
-
if (aggr.function.destructor) {
|
808
|
-
aggr.function.destructor(statef, aggr_input_data, count);
|
809
|
-
}
|
810
|
-
}
|
811
|
-
|
812
|
-
unique_ptr<WindowAggregatorState> WindowNaiveAggregator::GetLocalState(const WindowAggregatorState &gstate) const {
|
813
|
-
return make_uniq<WindowNaiveState>(*this);
|
814
|
-
}
|
815
|
-
|
816
|
-
void WindowNaiveAggregator::Evaluate(const WindowAggregatorState &gsink, WindowAggregatorState &lstate,
|
817
|
-
const DataChunk &bounds, Vector &result, idx_t count, idx_t row_idx) const {
|
818
|
-
const auto &gnstate = gsink.Cast<WindowAggregatorGlobalState>();
|
819
|
-
auto &lnstate = lstate.Cast<WindowNaiveState>();
|
820
|
-
lnstate.Evaluate(gnstate, bounds, result, count, row_idx);
|
821
|
-
}
|
822
|
-
|
823
|
-
//===--------------------------------------------------------------------===//
|
824
|
-
// WindowSegmentTree
|
825
|
-
//===--------------------------------------------------------------------===//
|
826
|
-
class WindowSegmentTreeGlobalState : public WindowAggregatorGlobalState {
|
827
|
-
public:
|
828
|
-
using AtomicCounters = vector<std::atomic<idx_t>>;
|
829
|
-
|
830
|
-
WindowSegmentTreeGlobalState(const WindowSegmentTree &aggregator, idx_t group_count);
|
831
|
-
|
832
|
-
ArenaAllocator &CreateTreeAllocator() {
|
833
|
-
lock_guard<mutex> tree_lock(lock);
|
834
|
-
tree_allocators.emplace_back(make_uniq<ArenaAllocator>(Allocator::DefaultAllocator()));
|
835
|
-
return *tree_allocators.back();
|
836
|
-
}
|
837
|
-
|
838
|
-
//! The owning aggregator
|
839
|
-
const WindowSegmentTree &tree;
|
840
|
-
//! The actual window segment tree: an array of aggregate states that represent all the intermediate nodes
|
841
|
-
WindowAggregateStates levels_flat_native;
|
842
|
-
//! For each level, the starting location in the levels_flat_native array
|
843
|
-
vector<idx_t> levels_flat_start;
|
844
|
-
//! The level being built (read)
|
845
|
-
std::atomic<idx_t> build_level;
|
846
|
-
//! The number of entries started so far at each level
|
847
|
-
unique_ptr<AtomicCounters> build_started;
|
848
|
-
//! The number of entries completed so far at each level
|
849
|
-
unique_ptr<AtomicCounters> build_completed;
|
850
|
-
//! The tree allocators.
|
851
|
-
//! We need to hold onto them for the tree lifetime,
|
852
|
-
//! not the lifetime of the local state that constructed part of the tree
|
853
|
-
vector<unique_ptr<ArenaAllocator>> tree_allocators;
|
854
|
-
|
855
|
-
// TREE_FANOUT needs to cleanly divide STANDARD_VECTOR_SIZE
|
856
|
-
static constexpr idx_t TREE_FANOUT = 16;
|
857
|
-
};
|
858
|
-
|
859
|
-
WindowSegmentTree::WindowSegmentTree(AggregateObject aggr, const vector<LogicalType> &arg_types,
|
860
|
-
const LogicalType &result_type, WindowAggregationMode mode_p,
|
861
|
-
const WindowExcludeMode exclude_mode_p)
|
862
|
-
: WindowAggregator(std::move(aggr), arg_types, result_type, exclude_mode_p), mode(mode_p) {
|
863
|
-
}
|
864
|
-
|
865
|
-
class WindowSegmentTreePart {
|
866
|
-
public:
|
867
|
-
//! Right side nodes need to be cached and processed in reverse order
|
868
|
-
using RightEntry = std::pair<idx_t, idx_t>;
|
869
|
-
|
870
|
-
enum FramePart : uint8_t { FULL = 0, LEFT = 1, RIGHT = 2 };
|
871
|
-
|
872
|
-
WindowSegmentTreePart(ArenaAllocator &allocator, const AggregateObject &aggr, const DataChunk &inputs,
|
873
|
-
const ValidityArray &filter_mask);
|
874
|
-
~WindowSegmentTreePart();
|
875
|
-
|
876
|
-
unique_ptr<WindowSegmentTreePart> Copy() const {
|
877
|
-
return make_uniq<WindowSegmentTreePart>(allocator, aggr, inputs, filter_mask);
|
878
|
-
}
|
879
|
-
|
880
|
-
void FlushStates(bool combining);
|
881
|
-
void ExtractFrame(idx_t begin, idx_t end, data_ptr_t current_state);
|
882
|
-
void WindowSegmentValue(const WindowSegmentTreeGlobalState &tree, idx_t l_idx, idx_t begin, idx_t end,
|
883
|
-
data_ptr_t current_state);
|
884
|
-
//! Writes result and calls destructors
|
885
|
-
void Finalize(Vector &result, idx_t count);
|
886
|
-
|
887
|
-
void Combine(WindowSegmentTreePart &other, idx_t count);
|
888
|
-
|
889
|
-
void Evaluate(const WindowSegmentTreeGlobalState &tree, const idx_t *begins, const idx_t *ends, Vector &result,
|
890
|
-
idx_t count, idx_t row_idx, FramePart frame_part);
|
891
|
-
|
892
|
-
protected:
|
893
|
-
//! Initialises the accumulation state vector (statef)
|
894
|
-
void Initialize(idx_t count);
|
895
|
-
//! Accumulate upper tree levels
|
896
|
-
void EvaluateUpperLevels(const WindowSegmentTreeGlobalState &tree, const idx_t *begins, const idx_t *ends,
|
897
|
-
idx_t count, idx_t row_idx, FramePart frame_part);
|
898
|
-
void EvaluateLeaves(const WindowSegmentTreeGlobalState &tree, const idx_t *begins, const idx_t *ends, idx_t count,
|
899
|
-
idx_t row_idx, FramePart frame_part, FramePart leaf_part);
|
900
|
-
|
901
|
-
public:
|
902
|
-
//! Allocator for aggregates
|
903
|
-
ArenaAllocator &allocator;
|
904
|
-
//! The aggregate function
|
905
|
-
const AggregateObject &aggr;
|
906
|
-
//! Order insensitive aggregate (we can optimise internal combines)
|
907
|
-
const bool order_insensitive;
|
908
|
-
//! The partition arguments
|
909
|
-
const DataChunk &inputs;
|
910
|
-
//! The filtered rows in inputs
|
911
|
-
const ValidityArray &filter_mask;
|
912
|
-
//! The size of a single aggregate state
|
913
|
-
const idx_t state_size;
|
914
|
-
//! Data pointer that contains a vector of states, used for intermediate window segment aggregation
|
915
|
-
vector<data_t> state;
|
916
|
-
//! Input data chunk, used for leaf segment aggregation
|
917
|
-
DataChunk leaves;
|
918
|
-
//! The filtered rows in inputs.
|
919
|
-
SelectionVector filter_sel;
|
920
|
-
//! A vector of pointers to "state", used for intermediate window segment aggregation
|
921
|
-
Vector statep;
|
922
|
-
//! Reused state pointers for combining segment tree levels
|
923
|
-
Vector statel;
|
924
|
-
//! Reused result state container for the window functions
|
925
|
-
Vector statef;
|
926
|
-
//! Count of buffered values
|
927
|
-
idx_t flush_count;
|
928
|
-
//! Cache of right side tree ranges for ordered aggregates
|
929
|
-
vector<RightEntry> right_stack;
|
930
|
-
};
|
931
|
-
|
932
|
-
class WindowSegmentTreeState : public WindowAggregatorState {
|
933
|
-
public:
|
934
|
-
WindowSegmentTreeState() {
|
935
|
-
}
|
936
|
-
|
937
|
-
void Finalize(WindowSegmentTreeGlobalState &gstate);
|
938
|
-
void Evaluate(const WindowSegmentTreeGlobalState &gsink, const DataChunk &bounds, Vector &result, idx_t count,
|
939
|
-
idx_t row_idx);
|
940
|
-
//! The left (default) segment tree part
|
941
|
-
unique_ptr<WindowSegmentTreePart> part;
|
942
|
-
//! The right segment tree part (for EXCLUDE)
|
943
|
-
unique_ptr<WindowSegmentTreePart> right_part;
|
944
|
-
};
|
945
|
-
|
946
|
-
void WindowSegmentTree::Finalize(WindowAggregatorState &gsink, WindowAggregatorState &lstate, const FrameStats &stats) {
|
947
|
-
|
948
|
-
auto &gasink = gsink.Cast<WindowSegmentTreeGlobalState>();
|
949
|
-
auto &inputs = gasink.inputs;
|
950
|
-
|
951
|
-
WindowAggregator::Finalize(gsink, lstate, stats);
|
952
|
-
|
953
|
-
if (inputs.ColumnCount() > 0) {
|
954
|
-
if (aggr.function.combine && UseCombineAPI()) {
|
955
|
-
lstate.Cast<WindowSegmentTreeState>().Finalize(gasink);
|
956
|
-
}
|
957
|
-
}
|
958
|
-
|
959
|
-
++gasink.finalized;
|
960
|
-
}
|
961
|
-
|
962
|
-
WindowSegmentTreePart::WindowSegmentTreePart(ArenaAllocator &allocator, const AggregateObject &aggr,
|
963
|
-
const DataChunk &inputs, const ValidityArray &filter_mask)
|
964
|
-
: allocator(allocator), aggr(aggr),
|
965
|
-
order_insensitive(aggr.function.order_dependent == AggregateOrderDependent::NOT_ORDER_DEPENDENT), inputs(inputs),
|
966
|
-
filter_mask(filter_mask), state_size(aggr.function.state_size(aggr.function)),
|
967
|
-
state(state_size * STANDARD_VECTOR_SIZE), statep(LogicalType::POINTER), statel(LogicalType::POINTER),
|
968
|
-
statef(LogicalType::POINTER), flush_count(0) {
|
969
|
-
if (inputs.ColumnCount() > 0) {
|
970
|
-
leaves.Initialize(Allocator::DefaultAllocator(), inputs.GetTypes());
|
971
|
-
filter_sel.Initialize();
|
972
|
-
}
|
973
|
-
|
974
|
-
// Build the finalise vector that just points to the result states
|
975
|
-
data_ptr_t state_ptr = state.data();
|
976
|
-
D_ASSERT(statef.GetVectorType() == VectorType::FLAT_VECTOR);
|
977
|
-
statef.SetVectorType(VectorType::CONSTANT_VECTOR);
|
978
|
-
statef.Flatten(STANDARD_VECTOR_SIZE);
|
979
|
-
auto fdata = FlatVector::GetData<data_ptr_t>(statef);
|
980
|
-
for (idx_t i = 0; i < STANDARD_VECTOR_SIZE; ++i) {
|
981
|
-
fdata[i] = state_ptr;
|
982
|
-
state_ptr += state_size;
|
983
|
-
}
|
984
|
-
}
|
985
|
-
|
986
|
-
WindowSegmentTreePart::~WindowSegmentTreePart() {
|
987
|
-
}
|
988
|
-
|
989
|
-
unique_ptr<WindowAggregatorState> WindowSegmentTree::GetGlobalState(idx_t group_count,
|
990
|
-
const ValidityMask &partition_mask) const {
|
991
|
-
return make_uniq<WindowSegmentTreeGlobalState>(*this, group_count);
|
992
|
-
}
|
993
|
-
|
994
|
-
unique_ptr<WindowAggregatorState> WindowSegmentTree::GetLocalState(const WindowAggregatorState &gstate) const {
|
995
|
-
return make_uniq<WindowSegmentTreeState>();
|
996
|
-
}
|
997
|
-
|
998
|
-
void WindowSegmentTreePart::FlushStates(bool combining) {
|
999
|
-
if (!flush_count) {
|
1000
|
-
return;
|
1001
|
-
}
|
1002
|
-
|
1003
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
1004
|
-
if (combining) {
|
1005
|
-
statel.Verify(flush_count);
|
1006
|
-
aggr.function.combine(statel, statep, aggr_input_data, flush_count);
|
1007
|
-
} else {
|
1008
|
-
leaves.Slice(inputs, filter_sel, flush_count);
|
1009
|
-
aggr.function.update(&leaves.data[0], aggr_input_data, leaves.ColumnCount(), statep, flush_count);
|
1010
|
-
}
|
1011
|
-
|
1012
|
-
flush_count = 0;
|
1013
|
-
}
|
1014
|
-
|
1015
|
-
void WindowSegmentTreePart::Combine(WindowSegmentTreePart &other, idx_t count) {
|
1016
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
1017
|
-
aggr.function.combine(other.statef, statef, aggr_input_data, count);
|
1018
|
-
}
|
1019
|
-
|
1020
|
-
void WindowSegmentTreePart::ExtractFrame(idx_t begin, idx_t end, data_ptr_t state_ptr) {
|
1021
|
-
const auto count = end - begin;
|
1022
|
-
|
1023
|
-
// If we are not filtering,
|
1024
|
-
// just update the shared dictionary selection to the range
|
1025
|
-
// Otherwise set it to the input rows that pass the filter
|
1026
|
-
auto states = FlatVector::GetData<data_ptr_t>(statep);
|
1027
|
-
if (filter_mask.AllValid()) {
|
1028
|
-
for (idx_t i = 0; i < count; ++i) {
|
1029
|
-
states[flush_count] = state_ptr;
|
1030
|
-
filter_sel.set_index(flush_count++, begin + i);
|
1031
|
-
if (flush_count >= STANDARD_VECTOR_SIZE) {
|
1032
|
-
FlushStates(false);
|
1033
|
-
}
|
1034
|
-
}
|
1035
|
-
} else {
|
1036
|
-
for (idx_t i = begin; i < end; ++i) {
|
1037
|
-
if (filter_mask.RowIsValid(i)) {
|
1038
|
-
states[flush_count] = state_ptr;
|
1039
|
-
filter_sel.set_index(flush_count++, i);
|
1040
|
-
if (flush_count >= STANDARD_VECTOR_SIZE) {
|
1041
|
-
FlushStates(false);
|
1042
|
-
}
|
1043
|
-
}
|
1044
|
-
}
|
1045
|
-
}
|
1046
|
-
}
|
1047
|
-
|
1048
|
-
void WindowSegmentTreePart::WindowSegmentValue(const WindowSegmentTreeGlobalState &tree, idx_t l_idx, idx_t begin,
|
1049
|
-
idx_t end, data_ptr_t state_ptr) {
|
1050
|
-
D_ASSERT(begin <= end);
|
1051
|
-
if (begin == end || inputs.ColumnCount() == 0) {
|
1052
|
-
return;
|
1053
|
-
}
|
1054
|
-
|
1055
|
-
const auto count = end - begin;
|
1056
|
-
if (l_idx == 0) {
|
1057
|
-
ExtractFrame(begin, end, state_ptr);
|
1058
|
-
} else {
|
1059
|
-
// find out where the states begin
|
1060
|
-
auto begin_ptr = tree.levels_flat_native.GetStatePtr(begin + tree.levels_flat_start[l_idx - 1]);
|
1061
|
-
// set up a vector of pointers that point towards the set of states
|
1062
|
-
auto ldata = FlatVector::GetData<const_data_ptr_t>(statel);
|
1063
|
-
auto pdata = FlatVector::GetData<data_ptr_t>(statep);
|
1064
|
-
for (idx_t i = 0; i < count; i++) {
|
1065
|
-
pdata[flush_count] = state_ptr;
|
1066
|
-
ldata[flush_count++] = begin_ptr;
|
1067
|
-
begin_ptr += state_size;
|
1068
|
-
if (flush_count >= STANDARD_VECTOR_SIZE) {
|
1069
|
-
FlushStates(true);
|
1070
|
-
}
|
1071
|
-
}
|
1072
|
-
}
|
1073
|
-
}
|
1074
|
-
void WindowSegmentTreePart::Finalize(Vector &result, idx_t count) {
|
1075
|
-
// Finalise the result aggregates and write to result if write_result is set
|
1076
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
1077
|
-
aggr.function.finalize(statef, aggr_input_data, result, count, 0);
|
1078
|
-
|
1079
|
-
// Destruct the result aggregates
|
1080
|
-
if (aggr.function.destructor) {
|
1081
|
-
aggr.function.destructor(statef, aggr_input_data, count);
|
1082
|
-
}
|
1083
|
-
}
|
1084
|
-
|
1085
|
-
WindowSegmentTreeGlobalState::WindowSegmentTreeGlobalState(const WindowSegmentTree &aggregator, idx_t group_count)
|
1086
|
-
: WindowAggregatorGlobalState(aggregator, group_count), tree(aggregator), levels_flat_native(aggregator.aggr) {
|
1087
|
-
|
1088
|
-
D_ASSERT(inputs.ColumnCount() > 0);
|
1089
|
-
|
1090
|
-
// compute space required to store internal nodes of segment tree
|
1091
|
-
levels_flat_start.push_back(0);
|
1092
|
-
|
1093
|
-
idx_t levels_flat_offset = 0;
|
1094
|
-
idx_t level_current = 0;
|
1095
|
-
// level 0 is data itself
|
1096
|
-
idx_t level_size;
|
1097
|
-
// iterate over the levels of the segment tree
|
1098
|
-
while ((level_size =
|
1099
|
-
(level_current == 0 ? inputs.size() : levels_flat_offset - levels_flat_start[level_current - 1])) > 1) {
|
1100
|
-
for (idx_t pos = 0; pos < level_size; pos += TREE_FANOUT) {
|
1101
|
-
levels_flat_offset++;
|
1102
|
-
}
|
1103
|
-
|
1104
|
-
levels_flat_start.push_back(levels_flat_offset);
|
1105
|
-
level_current++;
|
1106
|
-
}
|
1107
|
-
|
1108
|
-
// Corner case: single element in the window
|
1109
|
-
if (levels_flat_offset == 0) {
|
1110
|
-
++levels_flat_offset;
|
1111
|
-
}
|
1112
|
-
|
1113
|
-
levels_flat_native.Initialize(levels_flat_offset);
|
1114
|
-
|
1115
|
-
// Start by building from the bottom level
|
1116
|
-
build_level = 0;
|
1117
|
-
|
1118
|
-
build_started = make_uniq<AtomicCounters>(levels_flat_start.size());
|
1119
|
-
for (auto &counter : *build_started) {
|
1120
|
-
counter = 0;
|
1121
|
-
}
|
1122
|
-
|
1123
|
-
build_completed = make_uniq<AtomicCounters>(levels_flat_start.size());
|
1124
|
-
for (auto &counter : *build_completed) {
|
1125
|
-
counter = 0;
|
1126
|
-
}
|
1127
|
-
}
|
1128
|
-
|
1129
|
-
void WindowSegmentTreeState::Finalize(WindowSegmentTreeGlobalState &gstate) {
|
1130
|
-
// Single part for constructing the tree
|
1131
|
-
auto &inputs = gstate.inputs;
|
1132
|
-
auto &tree = gstate.tree;
|
1133
|
-
auto &filter_mask = gstate.filter_mask;
|
1134
|
-
WindowSegmentTreePart gtstate(gstate.CreateTreeAllocator(), tree.aggr, inputs, filter_mask);
|
1135
|
-
|
1136
|
-
auto &levels_flat_native = gstate.levels_flat_native;
|
1137
|
-
const auto &levels_flat_start = gstate.levels_flat_start;
|
1138
|
-
// iterate over the levels of the segment tree
|
1139
|
-
for (;;) {
|
1140
|
-
const idx_t level_current = gstate.build_level.load();
|
1141
|
-
if (level_current >= levels_flat_start.size()) {
|
1142
|
-
break;
|
1143
|
-
}
|
1144
|
-
|
1145
|
-
// level 0 is data itself
|
1146
|
-
const auto level_size =
|
1147
|
-
(level_current == 0 ? inputs.size()
|
1148
|
-
: levels_flat_start[level_current] - levels_flat_start[level_current - 1]);
|
1149
|
-
if (level_size <= 1) {
|
1150
|
-
break;
|
1151
|
-
}
|
1152
|
-
const idx_t build_count = (level_size + gstate.TREE_FANOUT - 1) / gstate.TREE_FANOUT;
|
1153
|
-
|
1154
|
-
// Build the next fan-in
|
1155
|
-
const idx_t build_idx = (*gstate.build_started).at(level_current)++;
|
1156
|
-
if (build_idx >= build_count) {
|
1157
|
-
// Nothing left at this level, so wait until other threads are done.
|
1158
|
-
// Since we are only building TREE_FANOUT values at a time, this will be quick.
|
1159
|
-
while (level_current == gstate.build_level.load()) {
|
1160
|
-
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
1161
|
-
}
|
1162
|
-
continue;
|
1163
|
-
}
|
1164
|
-
|
1165
|
-
// compute the aggregate for this entry in the segment tree
|
1166
|
-
const idx_t pos = build_idx * gstate.TREE_FANOUT;
|
1167
|
-
const idx_t levels_flat_offset = levels_flat_start[level_current] + build_idx;
|
1168
|
-
auto state_ptr = levels_flat_native.GetStatePtr(levels_flat_offset);
|
1169
|
-
gtstate.WindowSegmentValue(gstate, level_current, pos, MinValue(level_size, pos + gstate.TREE_FANOUT),
|
1170
|
-
state_ptr);
|
1171
|
-
gtstate.FlushStates(level_current > 0);
|
1172
|
-
|
1173
|
-
// If that was the last one, mark the level as complete.
|
1174
|
-
const idx_t build_complete = ++(*gstate.build_completed).at(level_current);
|
1175
|
-
if (build_complete == build_count) {
|
1176
|
-
gstate.build_level++;
|
1177
|
-
continue;
|
1178
|
-
}
|
1179
|
-
}
|
1180
|
-
}
|
1181
|
-
|
1182
|
-
void WindowSegmentTree::Evaluate(const WindowAggregatorState &gsink, WindowAggregatorState &lstate,
|
1183
|
-
const DataChunk &bounds, Vector &result, idx_t count, idx_t row_idx) const {
|
1184
|
-
const auto >state = gsink.Cast<WindowSegmentTreeGlobalState>();
|
1185
|
-
auto <state = lstate.Cast<WindowSegmentTreeState>();
|
1186
|
-
ltstate.Evaluate(gtstate, bounds, result, count, row_idx);
|
1187
|
-
}
|
1188
|
-
|
1189
|
-
void WindowSegmentTreeState::Evaluate(const WindowSegmentTreeGlobalState >state, const DataChunk &bounds,
|
1190
|
-
Vector &result, idx_t count, idx_t row_idx) {
|
1191
|
-
auto window_begin = FlatVector::GetData<const idx_t>(bounds.data[WINDOW_BEGIN]);
|
1192
|
-
auto window_end = FlatVector::GetData<const idx_t>(bounds.data[WINDOW_END]);
|
1193
|
-
auto peer_begin = FlatVector::GetData<const idx_t>(bounds.data[PEER_BEGIN]);
|
1194
|
-
auto peer_end = FlatVector::GetData<const idx_t>(bounds.data[PEER_END]);
|
1195
|
-
|
1196
|
-
if (!part) {
|
1197
|
-
part =
|
1198
|
-
make_uniq<WindowSegmentTreePart>(allocator, gtstate.aggregator.aggr, gtstate.inputs, gtstate.filter_mask);
|
1199
|
-
}
|
1200
|
-
|
1201
|
-
if (gtstate.aggregator.exclude_mode != WindowExcludeMode::NO_OTHER) {
|
1202
|
-
// 1. evaluate the tree left of the excluded part
|
1203
|
-
part->Evaluate(gtstate, window_begin, peer_begin, result, count, row_idx, WindowSegmentTreePart::LEFT);
|
1204
|
-
|
1205
|
-
// 2. set up a second state for the right of the excluded part
|
1206
|
-
if (!right_part) {
|
1207
|
-
right_part = part->Copy();
|
1208
|
-
}
|
1209
|
-
|
1210
|
-
// 3. evaluate the tree right of the excluded part
|
1211
|
-
right_part->Evaluate(gtstate, peer_end, window_end, result, count, row_idx, WindowSegmentTreePart::RIGHT);
|
1212
|
-
|
1213
|
-
// 4. combine the buffer state into the Segment Tree State
|
1214
|
-
part->Combine(*right_part, count);
|
1215
|
-
} else {
|
1216
|
-
part->Evaluate(gtstate, window_begin, window_end, result, count, row_idx, WindowSegmentTreePart::FULL);
|
1217
|
-
}
|
1218
|
-
|
1219
|
-
part->Finalize(result, count);
|
1220
|
-
}
|
1221
|
-
|
1222
|
-
void WindowSegmentTreePart::Evaluate(const WindowSegmentTreeGlobalState &tree, const idx_t *begins, const idx_t *ends,
|
1223
|
-
Vector &result, idx_t count, idx_t row_idx, FramePart frame_part) {
|
1224
|
-
Initialize(count);
|
1225
|
-
|
1226
|
-
if (order_insensitive) {
|
1227
|
-
// First pass: aggregate the segment tree nodes with sharing
|
1228
|
-
EvaluateUpperLevels(tree, begins, ends, count, row_idx, frame_part);
|
1229
|
-
|
1230
|
-
// Second pass: aggregate the ragged leaves
|
1231
|
-
EvaluateLeaves(tree, begins, ends, count, row_idx, frame_part, FramePart::FULL);
|
1232
|
-
} else {
|
1233
|
-
// Evaluate leaves in order
|
1234
|
-
EvaluateLeaves(tree, begins, ends, count, row_idx, frame_part, FramePart::LEFT);
|
1235
|
-
EvaluateUpperLevels(tree, begins, ends, count, row_idx, frame_part);
|
1236
|
-
EvaluateLeaves(tree, begins, ends, count, row_idx, frame_part, FramePart::RIGHT);
|
1237
|
-
}
|
1238
|
-
}
|
1239
|
-
|
1240
|
-
void WindowSegmentTreePart::Initialize(idx_t count) {
|
1241
|
-
auto fdata = FlatVector::GetData<data_ptr_t>(statef);
|
1242
|
-
for (idx_t rid = 0; rid < count; ++rid) {
|
1243
|
-
auto state_ptr = fdata[rid];
|
1244
|
-
aggr.function.initialize(aggr.function, state_ptr);
|
1245
|
-
}
|
1246
|
-
}
|
1247
|
-
|
1248
|
-
void WindowSegmentTreePart::EvaluateUpperLevels(const WindowSegmentTreeGlobalState &tree, const idx_t *begins,
|
1249
|
-
const idx_t *ends, idx_t count, idx_t row_idx, FramePart frame_part) {
|
1250
|
-
auto fdata = FlatVector::GetData<data_ptr_t>(statef);
|
1251
|
-
|
1252
|
-
const auto exclude_mode = tree.tree.exclude_mode;
|
1253
|
-
const bool begin_on_curr_row = frame_part == FramePart::RIGHT && exclude_mode == WindowExcludeMode::CURRENT_ROW;
|
1254
|
-
const bool end_on_curr_row = frame_part == FramePart::LEFT && exclude_mode == WindowExcludeMode::CURRENT_ROW;
|
1255
|
-
|
1256
|
-
const auto max_level = tree.levels_flat_start.size() + 1;
|
1257
|
-
right_stack.resize(max_level, {0, 0});
|
1258
|
-
|
1259
|
-
// Share adjacent identical states
|
1260
|
-
// We do this first because we want to share only tree aggregations
|
1261
|
-
idx_t prev_begin = 1;
|
1262
|
-
idx_t prev_end = 0;
|
1263
|
-
auto ldata = FlatVector::GetData<data_ptr_t>(statel);
|
1264
|
-
auto pdata = FlatVector::GetData<data_ptr_t>(statep);
|
1265
|
-
data_ptr_t prev_state = nullptr;
|
1266
|
-
for (idx_t rid = 0, cur_row = row_idx; rid < count; ++rid, ++cur_row) {
|
1267
|
-
auto state_ptr = fdata[rid];
|
1268
|
-
|
1269
|
-
auto begin = begin_on_curr_row ? cur_row + 1 : begins[rid];
|
1270
|
-
auto end = end_on_curr_row ? cur_row : ends[rid];
|
1271
|
-
if (begin >= end) {
|
1272
|
-
continue;
|
1273
|
-
}
|
1274
|
-
|
1275
|
-
// Skip level 0
|
1276
|
-
idx_t l_idx = 0;
|
1277
|
-
idx_t right_max = 0;
|
1278
|
-
for (; l_idx < max_level; l_idx++) {
|
1279
|
-
idx_t parent_begin = begin / tree.TREE_FANOUT;
|
1280
|
-
idx_t parent_end = end / tree.TREE_FANOUT;
|
1281
|
-
if (prev_state && l_idx == 1 && begin == prev_begin && end == prev_end) {
|
1282
|
-
// Just combine the previous top level result
|
1283
|
-
ldata[flush_count] = prev_state;
|
1284
|
-
pdata[flush_count] = state_ptr;
|
1285
|
-
if (++flush_count >= STANDARD_VECTOR_SIZE) {
|
1286
|
-
FlushStates(true);
|
1287
|
-
}
|
1288
|
-
break;
|
1289
|
-
}
|
1290
|
-
|
1291
|
-
if (order_insensitive && l_idx == 1) {
|
1292
|
-
prev_state = state_ptr;
|
1293
|
-
prev_begin = begin;
|
1294
|
-
prev_end = end;
|
1295
|
-
}
|
1296
|
-
|
1297
|
-
if (parent_begin == parent_end) {
|
1298
|
-
if (l_idx) {
|
1299
|
-
WindowSegmentValue(tree, l_idx, begin, end, state_ptr);
|
1300
|
-
}
|
1301
|
-
break;
|
1302
|
-
}
|
1303
|
-
idx_t group_begin = parent_begin * tree.TREE_FANOUT;
|
1304
|
-
if (begin != group_begin) {
|
1305
|
-
if (l_idx) {
|
1306
|
-
WindowSegmentValue(tree, l_idx, begin, group_begin + tree.TREE_FANOUT, state_ptr);
|
1307
|
-
}
|
1308
|
-
parent_begin++;
|
1309
|
-
}
|
1310
|
-
idx_t group_end = parent_end * tree.TREE_FANOUT;
|
1311
|
-
if (end != group_end) {
|
1312
|
-
if (l_idx) {
|
1313
|
-
if (order_insensitive) {
|
1314
|
-
WindowSegmentValue(tree, l_idx, group_end, end, state_ptr);
|
1315
|
-
} else {
|
1316
|
-
right_stack[l_idx] = {group_end, end};
|
1317
|
-
right_max = l_idx;
|
1318
|
-
}
|
1319
|
-
}
|
1320
|
-
}
|
1321
|
-
begin = parent_begin;
|
1322
|
-
end = parent_end;
|
1323
|
-
}
|
1324
|
-
|
1325
|
-
// Flush the right side values from left to right for order_sensitive aggregates
|
1326
|
-
// As we go up the tree, the right side ranges move left,
|
1327
|
-
// so we just cache them in a fixed size, preallocated array.
|
1328
|
-
// Then we can just reverse scan the array and append the cached ranges.
|
1329
|
-
for (l_idx = right_max; l_idx > 0; --l_idx) {
|
1330
|
-
auto &right_entry = right_stack[l_idx];
|
1331
|
-
const auto group_end = right_entry.first;
|
1332
|
-
const auto end = right_entry.second;
|
1333
|
-
if (end) {
|
1334
|
-
WindowSegmentValue(tree, l_idx, group_end, end, state_ptr);
|
1335
|
-
right_entry = {0, 0};
|
1336
|
-
}
|
1337
|
-
}
|
1338
|
-
}
|
1339
|
-
FlushStates(true);
|
1340
|
-
}
|
1341
|
-
|
1342
|
-
void WindowSegmentTreePart::EvaluateLeaves(const WindowSegmentTreeGlobalState &tree, const idx_t *begins,
|
1343
|
-
const idx_t *ends, idx_t count, idx_t row_idx, FramePart frame_part,
|
1344
|
-
FramePart leaf_part) {
|
1345
|
-
|
1346
|
-
auto fdata = FlatVector::GetData<data_ptr_t>(statef);
|
1347
|
-
|
1348
|
-
// For order-sensitive aggregates, we have to process the ragged leaves in two pieces.
|
1349
|
-
// The left side have to be added before the main tree followed by the ragged right sides.
|
1350
|
-
// The current row is the leftmost value of the right hand side.
|
1351
|
-
const bool compute_left = leaf_part != FramePart::RIGHT;
|
1352
|
-
const bool compute_right = leaf_part != FramePart::LEFT;
|
1353
|
-
const auto exclude_mode = tree.tree.exclude_mode;
|
1354
|
-
const bool begin_on_curr_row = frame_part == FramePart::RIGHT && exclude_mode == WindowExcludeMode::CURRENT_ROW;
|
1355
|
-
const bool end_on_curr_row = frame_part == FramePart::LEFT && exclude_mode == WindowExcludeMode::CURRENT_ROW;
|
1356
|
-
// with EXCLUDE TIES, in addition to the frame part right of the peer group's end, we also need to consider the
|
1357
|
-
// current row
|
1358
|
-
const bool add_curr_row = compute_left && frame_part == FramePart::RIGHT && exclude_mode == WindowExcludeMode::TIES;
|
1359
|
-
|
1360
|
-
for (idx_t rid = 0, cur_row = row_idx; rid < count; ++rid, ++cur_row) {
|
1361
|
-
auto state_ptr = fdata[rid];
|
1362
|
-
|
1363
|
-
const auto begin = begin_on_curr_row ? cur_row + 1 : begins[rid];
|
1364
|
-
const auto end = end_on_curr_row ? cur_row : ends[rid];
|
1365
|
-
if (add_curr_row) {
|
1366
|
-
WindowSegmentValue(tree, 0, cur_row, cur_row + 1, state_ptr);
|
1367
|
-
}
|
1368
|
-
if (begin >= end) {
|
1369
|
-
continue;
|
1370
|
-
}
|
1371
|
-
|
1372
|
-
idx_t parent_begin = begin / tree.TREE_FANOUT;
|
1373
|
-
idx_t parent_end = end / tree.TREE_FANOUT;
|
1374
|
-
if (parent_begin == parent_end) {
|
1375
|
-
if (compute_left) {
|
1376
|
-
WindowSegmentValue(tree, 0, begin, end, state_ptr);
|
1377
|
-
}
|
1378
|
-
continue;
|
1379
|
-
}
|
1380
|
-
|
1381
|
-
idx_t group_begin = parent_begin * tree.TREE_FANOUT;
|
1382
|
-
if (begin != group_begin && compute_left) {
|
1383
|
-
WindowSegmentValue(tree, 0, begin, group_begin + tree.TREE_FANOUT, state_ptr);
|
1384
|
-
}
|
1385
|
-
idx_t group_end = parent_end * tree.TREE_FANOUT;
|
1386
|
-
if (end != group_end && compute_right) {
|
1387
|
-
WindowSegmentValue(tree, 0, group_end, end, state_ptr);
|
1388
|
-
}
|
1389
|
-
}
|
1390
|
-
FlushStates(false);
|
1391
|
-
}
|
1392
|
-
|
1393
|
-
//===--------------------------------------------------------------------===//
|
1394
|
-
// WindowDistinctAggregator
|
1395
|
-
//===--------------------------------------------------------------------===//
|
1396
|
-
WindowDistinctAggregator::WindowDistinctAggregator(AggregateObject aggr, const vector<LogicalType> &arg_types,
|
1397
|
-
const LogicalType &result_type,
|
1398
|
-
const WindowExcludeMode exclude_mode_p, ClientContext &context)
|
1399
|
-
: WindowAggregator(std::move(aggr), arg_types, result_type, exclude_mode_p), context(context) {
|
1400
|
-
}
|
1401
|
-
|
1402
|
-
class WindowDistinctAggregatorLocalState;
|
1403
|
-
|
1404
|
-
class WindowDistinctAggregatorGlobalState;
|
1405
|
-
|
1406
|
-
class WindowDistinctSortTree : public MergeSortTree<idx_t, idx_t> {
|
1407
|
-
public:
|
1408
|
-
// prev_idx, input_idx
|
1409
|
-
using ZippedTuple = std::tuple<idx_t, idx_t>;
|
1410
|
-
using ZippedElements = vector<ZippedTuple>;
|
1411
|
-
|
1412
|
-
explicit WindowDistinctSortTree(WindowDistinctAggregatorGlobalState &gdastate, idx_t count) : gdastate(gdastate) {
|
1413
|
-
// Set up for parallel build
|
1414
|
-
build_level = 0;
|
1415
|
-
build_complete = 0;
|
1416
|
-
build_run = 0;
|
1417
|
-
build_run_length = 1;
|
1418
|
-
build_num_runs = count;
|
1419
|
-
}
|
1420
|
-
|
1421
|
-
void Build(WindowDistinctAggregatorLocalState &ldastate);
|
1422
|
-
|
1423
|
-
protected:
|
1424
|
-
bool TryNextRun(idx_t &level_idx, idx_t &run_idx);
|
1425
|
-
void BuildRun(idx_t level_nr, idx_t i, WindowDistinctAggregatorLocalState &ldastate);
|
1426
|
-
|
1427
|
-
WindowDistinctAggregatorGlobalState &gdastate;
|
1428
|
-
};
|
1429
|
-
|
1430
|
-
class WindowDistinctAggregatorGlobalState : public WindowAggregatorGlobalState {
|
1431
|
-
public:
|
1432
|
-
using GlobalSortStatePtr = unique_ptr<GlobalSortState>;
|
1433
|
-
using ZippedTuple = WindowDistinctSortTree::ZippedTuple;
|
1434
|
-
using ZippedElements = WindowDistinctSortTree::ZippedElements;
|
1435
|
-
|
1436
|
-
WindowDistinctAggregatorGlobalState(const WindowDistinctAggregator &aggregator, idx_t group_count);
|
1437
|
-
|
1438
|
-
//! Compute the block starts
|
1439
|
-
void MeasurePayloadBlocks();
|
1440
|
-
//! Patch up the previous index block boundaries
|
1441
|
-
void PatchPrevIdcs();
|
1442
|
-
bool TryPrepareNextStage(WindowDistinctAggregatorLocalState &lstate);
|
1443
|
-
|
1444
|
-
// Single threaded sorting for now
|
1445
|
-
ClientContext &context;
|
1446
|
-
idx_t memory_per_thread;
|
1447
|
-
|
1448
|
-
//! Finalize guard
|
1449
|
-
mutex lock;
|
1450
|
-
//! Finalize stage
|
1451
|
-
atomic<PartitionSortStage> stage;
|
1452
|
-
//! Tasks launched
|
1453
|
-
idx_t total_tasks = 0;
|
1454
|
-
//! Tasks launched
|
1455
|
-
idx_t tasks_assigned = 0;
|
1456
|
-
//! Tasks landed
|
1457
|
-
mutable atomic<idx_t> tasks_completed;
|
1458
|
-
|
1459
|
-
//! The sorted payload data types (partition index)
|
1460
|
-
vector<LogicalType> payload_types;
|
1461
|
-
//! The aggregate arguments + partition index
|
1462
|
-
vector<LogicalType> sort_types;
|
1463
|
-
|
1464
|
-
//! Sorting operations
|
1465
|
-
GlobalSortStatePtr global_sort;
|
1466
|
-
//! The block starts (the scanner doesn't know this) plus the total count
|
1467
|
-
vector<idx_t> block_starts;
|
1468
|
-
|
1469
|
-
//! The block boundary seconds
|
1470
|
-
mutable ZippedElements seconds;
|
1471
|
-
//! The MST with the distinct back pointers
|
1472
|
-
mutable MergeSortTree<ZippedTuple> zipped_tree;
|
1473
|
-
//! The merge sort tree for the aggregate.
|
1474
|
-
WindowDistinctSortTree merge_sort_tree;
|
1475
|
-
|
1476
|
-
//! The actual window segment tree: an array of aggregate states that represent all the intermediate nodes
|
1477
|
-
WindowAggregateStates levels_flat_native;
|
1478
|
-
//! For each level, the starting location in the levels_flat_native array
|
1479
|
-
vector<idx_t> levels_flat_start;
|
1480
|
-
};
|
1481
|
-
|
1482
|
-
WindowDistinctAggregatorGlobalState::WindowDistinctAggregatorGlobalState(const WindowDistinctAggregator &aggregator,
|
1483
|
-
idx_t group_count)
|
1484
|
-
: WindowAggregatorGlobalState(aggregator, group_count), context(aggregator.context),
|
1485
|
-
stage(PartitionSortStage::INIT), tasks_completed(0), merge_sort_tree(*this, group_count),
|
1486
|
-
levels_flat_native(aggregator.aggr) {
|
1487
|
-
payload_types.emplace_back(LogicalType::UBIGINT);
|
1488
|
-
|
1489
|
-
// 1: functionComputePrevIdcs(𝑖𝑛)
|
1490
|
-
// 2: sorted ← []
|
1491
|
-
// We sort the aggregate arguments and use the partition index as a tie-breaker.
|
1492
|
-
// TODO: Use a hash table?
|
1493
|
-
sort_types = aggregator.arg_types;
|
1494
|
-
for (const auto &type : payload_types) {
|
1495
|
-
sort_types.emplace_back(type);
|
1496
|
-
}
|
1497
|
-
|
1498
|
-
vector<BoundOrderByNode> orders;
|
1499
|
-
for (const auto &type : sort_types) {
|
1500
|
-
auto expr = make_uniq<BoundConstantExpression>(Value(type));
|
1501
|
-
orders.emplace_back(BoundOrderByNode(OrderType::ASCENDING, OrderByNullType::NULLS_FIRST, std::move(expr)));
|
1502
|
-
}
|
1503
|
-
|
1504
|
-
RowLayout payload_layout;
|
1505
|
-
payload_layout.Initialize(payload_types);
|
1506
|
-
|
1507
|
-
global_sort = make_uniq<GlobalSortState>(BufferManager::GetBufferManager(context), orders, payload_layout);
|
1508
|
-
|
1509
|
-
memory_per_thread = PhysicalOperator::GetMaxThreadMemory(context);
|
1510
|
-
|
1511
|
-
// 6: prevIdcs ← []
|
1512
|
-
// 7: prevIdcs[0] ← “-”
|
1513
|
-
auto &prev_idcs = zipped_tree.Allocate(group_count);
|
1514
|
-
|
1515
|
-
// To handle FILTER clauses we make the missing elements
|
1516
|
-
// point to themselves so they won't be counted.
|
1517
|
-
for (idx_t i = 0; i < group_count; ++i) {
|
1518
|
-
prev_idcs[i] = ZippedTuple(i + 1, i);
|
1519
|
-
}
|
1520
|
-
|
1521
|
-
// compute space required to store aggregation states of merge sort tree
|
1522
|
-
// this is one aggregate state per entry per level
|
1523
|
-
idx_t internal_nodes = 0;
|
1524
|
-
levels_flat_start.push_back(internal_nodes);
|
1525
|
-
for (idx_t level_nr = 0; level_nr < zipped_tree.tree.size(); ++level_nr) {
|
1526
|
-
internal_nodes += zipped_tree.tree[level_nr].first.size();
|
1527
|
-
levels_flat_start.push_back(internal_nodes);
|
1528
|
-
}
|
1529
|
-
levels_flat_native.Initialize(internal_nodes);
|
1530
|
-
|
1531
|
-
merge_sort_tree.tree.reserve(zipped_tree.tree.size());
|
1532
|
-
for (idx_t level_nr = 0; level_nr < zipped_tree.tree.size(); ++level_nr) {
|
1533
|
-
auto &zipped_level = zipped_tree.tree[level_nr].first;
|
1534
|
-
WindowDistinctSortTree::Elements level;
|
1535
|
-
WindowDistinctSortTree::Offsets cascades;
|
1536
|
-
level.resize(zipped_level.size());
|
1537
|
-
merge_sort_tree.tree.emplace_back(std::move(level), std::move(cascades));
|
1538
|
-
}
|
1539
|
-
}
|
1540
|
-
|
1541
|
-
class WindowDistinctAggregatorLocalState : public WindowAggregatorState {
|
1542
|
-
public:
|
1543
|
-
explicit WindowDistinctAggregatorLocalState(const WindowDistinctAggregatorGlobalState &aggregator);
|
1544
|
-
|
1545
|
-
void Sink(DataChunk &arg_chunk, idx_t input_idx, optional_ptr<SelectionVector> filter_sel, idx_t filtered);
|
1546
|
-
void Sorted();
|
1547
|
-
void ExecuteTask();
|
1548
|
-
void Evaluate(const WindowDistinctAggregatorGlobalState &gdstate, const DataChunk &bounds, Vector &result,
|
1549
|
-
idx_t count, idx_t row_idx);
|
1550
|
-
|
1551
|
-
//! Thread-local sorting data
|
1552
|
-
LocalSortState local_sort;
|
1553
|
-
//! Finalize stage
|
1554
|
-
PartitionSortStage stage = PartitionSortStage::INIT;
|
1555
|
-
//! Finalize scan block index
|
1556
|
-
idx_t block_idx;
|
1557
|
-
//! Thread-local tree aggregation
|
1558
|
-
Vector update_v;
|
1559
|
-
Vector source_v;
|
1560
|
-
Vector target_v;
|
1561
|
-
DataChunk leaves;
|
1562
|
-
SelectionVector sel;
|
1563
|
-
|
1564
|
-
protected:
|
1565
|
-
//! Flush the accumulated intermediate states into the result states
|
1566
|
-
void FlushStates();
|
1567
|
-
|
1568
|
-
//! The aggregator we are working with
|
1569
|
-
const WindowDistinctAggregatorGlobalState &gastate;
|
1570
|
-
DataChunk sort_chunk;
|
1571
|
-
DataChunk payload_chunk;
|
1572
|
-
//! Reused result state container for the window functions
|
1573
|
-
WindowAggregateStates statef;
|
1574
|
-
//! A vector of pointers to "state", used for buffering intermediate aggregates
|
1575
|
-
Vector statep;
|
1576
|
-
//! Reused state pointers for combining tree elements
|
1577
|
-
Vector statel;
|
1578
|
-
//! Count of buffered values
|
1579
|
-
idx_t flush_count;
|
1580
|
-
//! The frame boundaries, used for the window functions
|
1581
|
-
SubFrames frames;
|
1582
|
-
};
|
1583
|
-
|
1584
|
-
WindowDistinctAggregatorLocalState::WindowDistinctAggregatorLocalState(
|
1585
|
-
const WindowDistinctAggregatorGlobalState &gastate)
|
1586
|
-
: update_v(LogicalType::POINTER), source_v(LogicalType::POINTER), target_v(LogicalType::POINTER), gastate(gastate),
|
1587
|
-
statef(gastate.aggregator.aggr), statep(LogicalType::POINTER), statel(LogicalType::POINTER), flush_count(0) {
|
1588
|
-
InitSubFrames(frames, gastate.aggregator.exclude_mode);
|
1589
|
-
payload_chunk.Initialize(Allocator::DefaultAllocator(), gastate.payload_types);
|
1590
|
-
|
1591
|
-
auto &global_sort = gastate.global_sort;
|
1592
|
-
local_sort.Initialize(*global_sort, global_sort->buffer_manager);
|
1593
|
-
|
1594
|
-
sort_chunk.Initialize(Allocator::DefaultAllocator(), gastate.sort_types);
|
1595
|
-
sort_chunk.data.back().Reference(payload_chunk.data[0]);
|
1596
|
-
|
1597
|
-
//! Input data chunk, used for leaf segment aggregation
|
1598
|
-
leaves.Initialize(Allocator::DefaultAllocator(), gastate.inputs.GetTypes());
|
1599
|
-
sel.Initialize();
|
1600
|
-
|
1601
|
-
gastate.locals++;
|
1602
|
-
}
|
1603
|
-
|
1604
|
-
unique_ptr<WindowAggregatorState> WindowDistinctAggregator::GetGlobalState(idx_t group_count,
|
1605
|
-
const ValidityMask &partition_mask) const {
|
1606
|
-
return make_uniq<WindowDistinctAggregatorGlobalState>(*this, group_count);
|
1607
|
-
}
|
1608
|
-
|
1609
|
-
void WindowDistinctAggregator::Sink(WindowAggregatorState &gsink, WindowAggregatorState &lstate, DataChunk &arg_chunk,
|
1610
|
-
idx_t input_idx, optional_ptr<SelectionVector> filter_sel, idx_t filtered) {
|
1611
|
-
WindowAggregator::Sink(gsink, lstate, arg_chunk, input_idx, filter_sel, filtered);
|
1612
|
-
|
1613
|
-
auto &ldstate = lstate.Cast<WindowDistinctAggregatorLocalState>();
|
1614
|
-
ldstate.Sink(arg_chunk, input_idx, filter_sel, filtered);
|
1615
|
-
}
|
1616
|
-
|
1617
|
-
void WindowDistinctAggregatorLocalState::Sink(DataChunk &arg_chunk, idx_t input_idx,
|
1618
|
-
optional_ptr<SelectionVector> filter_sel, idx_t filtered) {
|
1619
|
-
// 3: for i ← 0 to in.size do
|
1620
|
-
// 4: sorted[i] ← (in[i], i)
|
1621
|
-
const auto count = arg_chunk.size();
|
1622
|
-
payload_chunk.Reset();
|
1623
|
-
auto &sorted_vec = payload_chunk.data[0];
|
1624
|
-
auto sorted = FlatVector::GetData<idx_t>(sorted_vec);
|
1625
|
-
std::iota(sorted, sorted + count, input_idx);
|
1626
|
-
|
1627
|
-
for (column_t c = 0; c < arg_chunk.ColumnCount(); ++c) {
|
1628
|
-
sort_chunk.data[c].Reference(arg_chunk.data[c]);
|
1629
|
-
}
|
1630
|
-
sort_chunk.data.back().Reference(sorted_vec);
|
1631
|
-
sort_chunk.SetCardinality(arg_chunk);
|
1632
|
-
payload_chunk.SetCardinality(sort_chunk);
|
1633
|
-
|
1634
|
-
// Apply FILTER clause, if any
|
1635
|
-
if (filter_sel) {
|
1636
|
-
sort_chunk.Slice(*filter_sel, filtered);
|
1637
|
-
payload_chunk.Slice(*filter_sel, filtered);
|
1638
|
-
}
|
1639
|
-
|
1640
|
-
local_sort.SinkChunk(sort_chunk, payload_chunk);
|
1641
|
-
|
1642
|
-
if (local_sort.SizeInBytes() > gastate.memory_per_thread) {
|
1643
|
-
local_sort.Sort(*gastate.global_sort, true);
|
1644
|
-
}
|
1645
|
-
}
|
1646
|
-
|
1647
|
-
void WindowDistinctAggregatorLocalState::ExecuteTask() {
|
1648
|
-
auto &global_sort = *gastate.global_sort;
|
1649
|
-
switch (stage) {
|
1650
|
-
case PartitionSortStage::INIT:
|
1651
|
-
// AddLocalState is thread-safe
|
1652
|
-
global_sort.AddLocalState(local_sort);
|
1653
|
-
break;
|
1654
|
-
case PartitionSortStage::MERGE: {
|
1655
|
-
MergeSorter merge_sorter(global_sort, global_sort.buffer_manager);
|
1656
|
-
merge_sorter.PerformInMergeRound();
|
1657
|
-
break;
|
1658
|
-
}
|
1659
|
-
case PartitionSortStage::SORTED:
|
1660
|
-
Sorted();
|
1661
|
-
break;
|
1662
|
-
default:
|
1663
|
-
break;
|
1664
|
-
}
|
1665
|
-
|
1666
|
-
++gastate.tasks_completed;
|
1667
|
-
}
|
1668
|
-
|
1669
|
-
void WindowDistinctAggregatorGlobalState::MeasurePayloadBlocks() {
|
1670
|
-
const auto &blocks = global_sort->sorted_blocks[0]->payload_data->data_blocks;
|
1671
|
-
idx_t count = 0;
|
1672
|
-
for (const auto &block : blocks) {
|
1673
|
-
block_starts.emplace_back(count);
|
1674
|
-
count += block->count;
|
1675
|
-
}
|
1676
|
-
block_starts.emplace_back(count);
|
1677
|
-
}
|
1678
|
-
|
1679
|
-
bool WindowDistinctAggregatorGlobalState::TryPrepareNextStage(WindowDistinctAggregatorLocalState &lstate) {
|
1680
|
-
lock_guard<mutex> stage_guard(lock);
|
1681
|
-
|
1682
|
-
switch (stage.load()) {
|
1683
|
-
case PartitionSortStage::INIT:
|
1684
|
-
// Wait for all the local sorts to be processed
|
1685
|
-
if (tasks_completed < locals) {
|
1686
|
-
return false;
|
1687
|
-
}
|
1688
|
-
global_sort->PrepareMergePhase();
|
1689
|
-
if (!(global_sort->sorted_blocks.size() / 2)) {
|
1690
|
-
if (global_sort->sorted_blocks.empty()) {
|
1691
|
-
lstate.stage = stage = PartitionSortStage::FINISHED;
|
1692
|
-
return true;
|
1693
|
-
}
|
1694
|
-
MeasurePayloadBlocks();
|
1695
|
-
seconds.resize(block_starts.size() - 1);
|
1696
|
-
total_tasks = seconds.size();
|
1697
|
-
tasks_completed = 0;
|
1698
|
-
tasks_assigned = 0;
|
1699
|
-
lstate.stage = stage = PartitionSortStage::SORTED;
|
1700
|
-
lstate.block_idx = tasks_assigned++;
|
1701
|
-
return true;
|
1702
|
-
}
|
1703
|
-
global_sort->InitializeMergeRound();
|
1704
|
-
lstate.stage = stage = PartitionSortStage::MERGE;
|
1705
|
-
total_tasks = locals;
|
1706
|
-
tasks_assigned = 1;
|
1707
|
-
tasks_completed = 0;
|
1708
|
-
return true;
|
1709
|
-
case PartitionSortStage::MERGE:
|
1710
|
-
if (tasks_assigned < total_tasks) {
|
1711
|
-
lstate.stage = PartitionSortStage::MERGE;
|
1712
|
-
++tasks_assigned;
|
1713
|
-
return true;
|
1714
|
-
} else if (tasks_completed < tasks_assigned) {
|
1715
|
-
return false;
|
1716
|
-
}
|
1717
|
-
global_sort->CompleteMergeRound(true);
|
1718
|
-
if (!(global_sort->sorted_blocks.size() / 2)) {
|
1719
|
-
MeasurePayloadBlocks();
|
1720
|
-
seconds.resize(block_starts.size() - 1);
|
1721
|
-
total_tasks = seconds.size();
|
1722
|
-
tasks_completed = 0;
|
1723
|
-
tasks_assigned = 0;
|
1724
|
-
lstate.stage = stage = PartitionSortStage::SORTED;
|
1725
|
-
lstate.block_idx = tasks_assigned++;
|
1726
|
-
return true;
|
1727
|
-
}
|
1728
|
-
global_sort->InitializeMergeRound();
|
1729
|
-
lstate.stage = PartitionSortStage::MERGE;
|
1730
|
-
total_tasks = locals;
|
1731
|
-
tasks_assigned = 1;
|
1732
|
-
tasks_completed = 0;
|
1733
|
-
return true;
|
1734
|
-
case PartitionSortStage::SORTED:
|
1735
|
-
if (tasks_assigned < total_tasks) {
|
1736
|
-
lstate.stage = PartitionSortStage::SORTED;
|
1737
|
-
lstate.block_idx = tasks_assigned++;
|
1738
|
-
return true;
|
1739
|
-
} else if (tasks_completed < tasks_assigned) {
|
1740
|
-
lstate.stage = PartitionSortStage::FINISHED;
|
1741
|
-
// Sleep while other tasks finish
|
1742
|
-
return false;
|
1743
|
-
}
|
1744
|
-
// Last task patches the boundaries
|
1745
|
-
PatchPrevIdcs();
|
1746
|
-
break;
|
1747
|
-
default:
|
1748
|
-
break;
|
1749
|
-
}
|
1750
|
-
|
1751
|
-
lstate.stage = stage = PartitionSortStage::FINISHED;
|
1752
|
-
|
1753
|
-
return true;
|
1754
|
-
}
|
1755
|
-
|
1756
|
-
void WindowDistinctAggregator::Finalize(WindowAggregatorState &gsink, WindowAggregatorState &lstate,
|
1757
|
-
const FrameStats &stats) {
|
1758
|
-
auto &gdsink = gsink.Cast<WindowDistinctAggregatorGlobalState>();
|
1759
|
-
auto &ldstate = lstate.Cast<WindowDistinctAggregatorLocalState>();
|
1760
|
-
|
1761
|
-
// 5: Sort sorted lexicographically increasing
|
1762
|
-
ldstate.ExecuteTask();
|
1763
|
-
|
1764
|
-
// Merge in parallel
|
1765
|
-
while (gdsink.stage.load() != PartitionSortStage::FINISHED) {
|
1766
|
-
if (gdsink.TryPrepareNextStage(ldstate)) {
|
1767
|
-
ldstate.ExecuteTask();
|
1768
|
-
} else {
|
1769
|
-
std::this_thread::yield();
|
1770
|
-
}
|
1771
|
-
}
|
1772
|
-
|
1773
|
-
// These are a parallel implementations,
|
1774
|
-
// so every thread can call them.
|
1775
|
-
gdsink.zipped_tree.Build();
|
1776
|
-
gdsink.merge_sort_tree.Build(ldstate);
|
1777
|
-
|
1778
|
-
++gdsink.finalized;
|
1779
|
-
}
|
1780
|
-
|
1781
|
-
void WindowDistinctAggregatorLocalState::Sorted() {
|
1782
|
-
using ZippedTuple = WindowDistinctAggregatorGlobalState::ZippedTuple;
|
1783
|
-
auto &global_sort = gastate.global_sort;
|
1784
|
-
auto &prev_idcs = gastate.zipped_tree.LowestLevel();
|
1785
|
-
auto &aggregator = gastate.aggregator;
|
1786
|
-
auto &scan_chunk = payload_chunk;
|
1787
|
-
|
1788
|
-
auto scanner = make_uniq<PayloadScanner>(*global_sort, block_idx);
|
1789
|
-
const auto in_size = gastate.block_starts.at(block_idx + 1);
|
1790
|
-
scanner->Scan(scan_chunk);
|
1791
|
-
idx_t scan_idx = 0;
|
1792
|
-
|
1793
|
-
auto *input_idx = FlatVector::GetData<idx_t>(scan_chunk.data[0]);
|
1794
|
-
idx_t i = 0;
|
1795
|
-
|
1796
|
-
SBIterator curr(*global_sort, ExpressionType::COMPARE_LESSTHAN);
|
1797
|
-
SBIterator prev(*global_sort, ExpressionType::COMPARE_LESSTHAN);
|
1798
|
-
auto prefix_layout = global_sort->sort_layout.GetPrefixComparisonLayout(aggregator.arg_types.size());
|
1799
|
-
|
1800
|
-
const auto block_begin = gastate.block_starts.at(block_idx);
|
1801
|
-
if (!block_begin) {
|
1802
|
-
// First block, so set up initial sentinel
|
1803
|
-
i = input_idx[scan_idx++];
|
1804
|
-
prev_idcs[i] = ZippedTuple(0, i);
|
1805
|
-
std::get<0>(gastate.seconds[block_idx]) = i;
|
1806
|
-
} else {
|
1807
|
-
// Move to the to end of the previous block
|
1808
|
-
// so we can record the comparison result for the first row
|
1809
|
-
curr.SetIndex(block_begin - 1);
|
1810
|
-
prev.SetIndex(block_begin - 1);
|
1811
|
-
scan_idx = 0;
|
1812
|
-
std::get<0>(gastate.seconds[block_idx]) = input_idx[scan_idx];
|
1813
|
-
}
|
1814
|
-
|
1815
|
-
// 8: for i ← 1 to in.size do
|
1816
|
-
for (++curr; curr.GetIndex() < in_size; ++curr, ++prev) {
|
1817
|
-
// Scan second one chunk at a time
|
1818
|
-
// Note the scan is one behind the iterators
|
1819
|
-
if (scan_idx >= scan_chunk.size()) {
|
1820
|
-
scan_chunk.Reset();
|
1821
|
-
scanner->Scan(scan_chunk);
|
1822
|
-
scan_idx = 0;
|
1823
|
-
input_idx = FlatVector::GetData<idx_t>(scan_chunk.data[0]);
|
1824
|
-
}
|
1825
|
-
auto second = i;
|
1826
|
-
i = input_idx[scan_idx++];
|
1827
|
-
|
1828
|
-
int lt = 0;
|
1829
|
-
if (prefix_layout.all_constant) {
|
1830
|
-
lt = FastMemcmp(prev.entry_ptr, curr.entry_ptr, prefix_layout.comparison_size);
|
1831
|
-
} else {
|
1832
|
-
lt = Comparators::CompareTuple(prev.scan, curr.scan, prev.entry_ptr, curr.entry_ptr, prefix_layout,
|
1833
|
-
prev.external);
|
1834
|
-
}
|
1835
|
-
|
1836
|
-
// 9: if sorted[i].first == sorted[i-1].first then
|
1837
|
-
// 10: prevIdcs[i] ← sorted[i-1].second
|
1838
|
-
// 11: else
|
1839
|
-
// 12: prevIdcs[i] ← “-”
|
1840
|
-
if (!lt) {
|
1841
|
-
prev_idcs[i] = ZippedTuple(second + 1, i);
|
1842
|
-
} else {
|
1843
|
-
prev_idcs[i] = ZippedTuple(0, i);
|
1844
|
-
}
|
1845
|
-
}
|
1846
|
-
|
1847
|
-
// Save the last value of i for patching up the block boundaries
|
1848
|
-
std::get<1>(gastate.seconds[block_idx]) = i;
|
1849
|
-
}
|
1850
|
-
|
1851
|
-
void WindowDistinctAggregatorGlobalState::PatchPrevIdcs() {
|
1852
|
-
// 13: return prevIdcs
|
1853
|
-
|
1854
|
-
// Patch up the indices at block boundaries
|
1855
|
-
// (We don't need to patch block 0.)
|
1856
|
-
auto &prev_idcs = zipped_tree.LowestLevel();
|
1857
|
-
for (idx_t block_idx = 1; block_idx < seconds.size(); ++block_idx) {
|
1858
|
-
// We only need to patch if the first index in the block
|
1859
|
-
// was a back link to the previous block (10:)
|
1860
|
-
auto i = std::get<0>(seconds.at(block_idx));
|
1861
|
-
if (std::get<0>(prev_idcs[i])) {
|
1862
|
-
auto second = std::get<1>(seconds.at(block_idx - 1));
|
1863
|
-
prev_idcs[i] = ZippedTuple(second + 1, i);
|
1864
|
-
}
|
1865
|
-
}
|
1866
|
-
}
|
1867
|
-
|
1868
|
-
bool WindowDistinctSortTree::TryNextRun(idx_t &level_idx, idx_t &run_idx) {
|
1869
|
-
const auto fanout = FANOUT;
|
1870
|
-
|
1871
|
-
lock_guard<mutex> stage_guard(build_lock);
|
1872
|
-
|
1873
|
-
// Verify we are not done
|
1874
|
-
if (build_level >= tree.size()) {
|
1875
|
-
return false;
|
1876
|
-
}
|
1877
|
-
|
1878
|
-
// Finished with this level?
|
1879
|
-
if (build_complete >= build_num_runs) {
|
1880
|
-
auto &zipped_tree = gdastate.zipped_tree;
|
1881
|
-
std::swap(tree[build_level].second, zipped_tree.tree[build_level].second);
|
1882
|
-
|
1883
|
-
++build_level;
|
1884
|
-
if (build_level >= tree.size()) {
|
1885
|
-
zipped_tree.tree.clear();
|
1886
|
-
return false;
|
1887
|
-
}
|
1888
|
-
|
1889
|
-
const auto count = LowestLevel().size();
|
1890
|
-
build_run_length *= fanout;
|
1891
|
-
build_num_runs = (count + build_run_length - 1) / build_run_length;
|
1892
|
-
build_run = 0;
|
1893
|
-
build_complete = 0;
|
1894
|
-
}
|
1895
|
-
|
1896
|
-
// If all runs are in flight,
|
1897
|
-
// yield until the next level is ready
|
1898
|
-
if (build_run >= build_num_runs) {
|
1899
|
-
return false;
|
1900
|
-
}
|
1901
|
-
|
1902
|
-
level_idx = build_level;
|
1903
|
-
run_idx = build_run++;
|
1904
|
-
|
1905
|
-
return true;
|
1906
|
-
}
|
1907
|
-
|
1908
|
-
void WindowDistinctSortTree::Build(WindowDistinctAggregatorLocalState &ldastate) {
|
1909
|
-
// Fan in parent levels until we are at the top
|
1910
|
-
// Note that we don't build the top layer as that would just be all the data.
|
1911
|
-
while (build_level.load() < tree.size()) {
|
1912
|
-
idx_t level_idx;
|
1913
|
-
idx_t run_idx;
|
1914
|
-
if (TryNextRun(level_idx, run_idx)) {
|
1915
|
-
BuildRun(level_idx, run_idx, ldastate);
|
1916
|
-
} else {
|
1917
|
-
std::this_thread::yield();
|
1918
|
-
}
|
1919
|
-
}
|
1920
|
-
}
|
1921
|
-
|
1922
|
-
void WindowDistinctSortTree::BuildRun(idx_t level_nr, idx_t run_idx, WindowDistinctAggregatorLocalState &ldastate) {
|
1923
|
-
auto &aggr = gdastate.aggregator.aggr;
|
1924
|
-
auto &allocator = gdastate.allocator;
|
1925
|
-
auto &inputs = gdastate.inputs;
|
1926
|
-
auto &levels_flat_native = gdastate.levels_flat_native;
|
1927
|
-
|
1928
|
-
//! Input data chunk, used for leaf segment aggregation
|
1929
|
-
auto &leaves = ldastate.leaves;
|
1930
|
-
auto &sel = ldastate.sel;
|
1931
|
-
|
1932
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
1933
|
-
|
1934
|
-
//! The states to update
|
1935
|
-
auto &update_v = ldastate.update_v;
|
1936
|
-
auto updates = FlatVector::GetData<data_ptr_t>(update_v);
|
1937
|
-
|
1938
|
-
auto &source_v = ldastate.source_v;
|
1939
|
-
auto sources = FlatVector::GetData<data_ptr_t>(source_v);
|
1940
|
-
auto &target_v = ldastate.target_v;
|
1941
|
-
auto targets = FlatVector::GetData<data_ptr_t>(target_v);
|
1942
|
-
|
1943
|
-
auto &zipped_tree = gdastate.zipped_tree;
|
1944
|
-
auto &zipped_level = zipped_tree.tree[level_nr].first;
|
1945
|
-
auto &level = tree[level_nr].first;
|
1946
|
-
|
1947
|
-
// Reset the combine state
|
1948
|
-
idx_t nupdate = 0;
|
1949
|
-
idx_t ncombine = 0;
|
1950
|
-
data_ptr_t prev_state = nullptr;
|
1951
|
-
idx_t i = run_idx * build_run_length;
|
1952
|
-
auto next_limit = MinValue<idx_t>(zipped_level.size(), i + build_run_length);
|
1953
|
-
idx_t levels_flat_offset = level_nr * zipped_level.size() + i;
|
1954
|
-
for (auto j = i; j < next_limit; ++j) {
|
1955
|
-
// Initialise the next aggregate
|
1956
|
-
auto curr_state = levels_flat_native.GetStatePtr(levels_flat_offset++);
|
1957
|
-
|
1958
|
-
// Update this state (if it matches)
|
1959
|
-
const auto prev_idx = std::get<0>(zipped_level[j]);
|
1960
|
-
level[j] = prev_idx;
|
1961
|
-
if (prev_idx < i + 1) {
|
1962
|
-
updates[nupdate] = curr_state;
|
1963
|
-
// input_idx
|
1964
|
-
sel[nupdate] = UnsafeNumericCast<sel_t>(std::get<1>(zipped_level[j]));
|
1965
|
-
++nupdate;
|
1966
|
-
}
|
1967
|
-
|
1968
|
-
// Merge the previous state (if any)
|
1969
|
-
if (prev_state) {
|
1970
|
-
sources[ncombine] = prev_state;
|
1971
|
-
targets[ncombine] = curr_state;
|
1972
|
-
++ncombine;
|
1973
|
-
}
|
1974
|
-
prev_state = curr_state;
|
1975
|
-
|
1976
|
-
// Flush the states if one is maxed out.
|
1977
|
-
if (MaxValue<idx_t>(ncombine, nupdate) >= STANDARD_VECTOR_SIZE) {
|
1978
|
-
// Push the updates first so they propagate
|
1979
|
-
leaves.Reference(inputs);
|
1980
|
-
leaves.Slice(sel, nupdate);
|
1981
|
-
aggr.function.update(leaves.data.data(), aggr_input_data, leaves.ColumnCount(), update_v, nupdate);
|
1982
|
-
nupdate = 0;
|
1983
|
-
|
1984
|
-
// Combine the states sequentially
|
1985
|
-
aggr.function.combine(source_v, target_v, aggr_input_data, ncombine);
|
1986
|
-
ncombine = 0;
|
1987
|
-
}
|
1988
|
-
}
|
1989
|
-
|
1990
|
-
// Flush any remaining states
|
1991
|
-
if (ncombine || nupdate) {
|
1992
|
-
// Push the updates
|
1993
|
-
leaves.Reference(inputs);
|
1994
|
-
leaves.Slice(sel, nupdate);
|
1995
|
-
aggr.function.update(leaves.data.data(), aggr_input_data, leaves.ColumnCount(), update_v, nupdate);
|
1996
|
-
nupdate = 0;
|
1997
|
-
|
1998
|
-
// Combine the states sequentially
|
1999
|
-
aggr.function.combine(source_v, target_v, aggr_input_data, ncombine);
|
2000
|
-
ncombine = 0;
|
2001
|
-
}
|
2002
|
-
|
2003
|
-
++build_complete;
|
2004
|
-
}
|
2005
|
-
|
2006
|
-
void WindowDistinctAggregatorLocalState::FlushStates() {
|
2007
|
-
if (!flush_count) {
|
2008
|
-
return;
|
2009
|
-
}
|
2010
|
-
|
2011
|
-
const auto &aggr = gastate.aggregator.aggr;
|
2012
|
-
AggregateInputData aggr_input_data(aggr.GetFunctionData(), allocator);
|
2013
|
-
statel.Verify(flush_count);
|
2014
|
-
aggr.function.combine(statel, statep, aggr_input_data, flush_count);
|
2015
|
-
|
2016
|
-
flush_count = 0;
|
2017
|
-
}
|
2018
|
-
|
2019
|
-
void WindowDistinctAggregatorLocalState::Evaluate(const WindowDistinctAggregatorGlobalState &gdstate,
|
2020
|
-
const DataChunk &bounds, Vector &result, idx_t count, idx_t row_idx) {
|
2021
|
-
auto ldata = FlatVector::GetData<const_data_ptr_t>(statel);
|
2022
|
-
auto pdata = FlatVector::GetData<data_ptr_t>(statep);
|
2023
|
-
|
2024
|
-
const auto &merge_sort_tree = gdstate.merge_sort_tree;
|
2025
|
-
const auto &levels_flat_native = gdstate.levels_flat_native;
|
2026
|
-
const auto exclude_mode = gdstate.aggregator.exclude_mode;
|
2027
|
-
|
2028
|
-
// Build the finalise vector that just points to the result states
|
2029
|
-
statef.Initialize(count);
|
2030
|
-
|
2031
|
-
EvaluateSubFrames(bounds, exclude_mode, count, row_idx, frames, [&](idx_t rid) {
|
2032
|
-
auto agg_state = statef.GetStatePtr(rid);
|
2033
|
-
|
2034
|
-
// TODO: Extend AggregateLowerBound to handle subframes, just like SelectNth.
|
2035
|
-
const auto lower = frames[0].start;
|
2036
|
-
const auto upper = frames[0].end;
|
2037
|
-
merge_sort_tree.AggregateLowerBound(lower, upper, lower + 1,
|
2038
|
-
[&](idx_t level, const idx_t run_begin, const idx_t run_pos) {
|
2039
|
-
if (run_pos != run_begin) {
|
2040
|
-
// Find the source aggregate
|
2041
|
-
// Buffer a merge of the indicated state into the current state
|
2042
|
-
const auto agg_idx = gdstate.levels_flat_start[level] + run_pos - 1;
|
2043
|
-
const auto running_agg = levels_flat_native.GetStatePtr(agg_idx);
|
2044
|
-
pdata[flush_count] = agg_state;
|
2045
|
-
ldata[flush_count++] = running_agg;
|
2046
|
-
if (flush_count >= STANDARD_VECTOR_SIZE) {
|
2047
|
-
FlushStates();
|
2048
|
-
}
|
2049
|
-
}
|
2050
|
-
});
|
2051
|
-
});
|
2052
|
-
|
2053
|
-
// Flush the final states
|
2054
|
-
FlushStates();
|
2055
|
-
|
2056
|
-
// Finalise the result aggregates and write to the result
|
2057
|
-
statef.Finalize(result);
|
2058
|
-
statef.Destroy();
|
2059
|
-
}
|
2060
|
-
|
2061
|
-
unique_ptr<WindowAggregatorState> WindowDistinctAggregator::GetLocalState(const WindowAggregatorState &gstate) const {
|
2062
|
-
return make_uniq<WindowDistinctAggregatorLocalState>(gstate.Cast<const WindowDistinctAggregatorGlobalState>());
|
2063
|
-
}
|
2064
|
-
|
2065
|
-
void WindowDistinctAggregator::Evaluate(const WindowAggregatorState &gsink, WindowAggregatorState &lstate,
|
2066
|
-
const DataChunk &bounds, Vector &result, idx_t count, idx_t row_idx) const {
|
2067
|
-
|
2068
|
-
const auto &gdstate = gsink.Cast<WindowDistinctAggregatorGlobalState>();
|
2069
|
-
auto &ldstate = lstate.Cast<WindowDistinctAggregatorLocalState>();
|
2070
|
-
ldstate.Evaluate(gdstate, bounds, result, count, row_idx);
|
2071
|
-
}
|
2072
|
-
|
2073
|
-
} // namespace duckdb
|