duckdb 0.3.2-dev50.0 → 0.3.2-dev70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb.cpp +234 -46
- package/src/duckdb.hpp +5 -2
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -9481,6 +9481,7 @@ static DefaultMacro internal_macros[] = {
|
|
|
9481
9481
|
{DEFAULT_SCHEMA, "array_append", {"arr", "el", nullptr}, "list_append(arr, el)"},
|
|
9482
9482
|
{DEFAULT_SCHEMA, "list_prepend", {"e", "l", nullptr}, "list_concat(list_value(e), l)"},
|
|
9483
9483
|
{DEFAULT_SCHEMA, "array_prepend", {"el", "arr", nullptr}, "list_prepend(el, arr)"},
|
|
9484
|
+
{DEFAULT_SCHEMA, "generate_subscripts", {"arr", "dim", nullptr}, "unnest(generate_series(1, array_length(arr, dim)))"},
|
|
9484
9485
|
{nullptr, nullptr, {nullptr}, nullptr}};
|
|
9485
9486
|
|
|
9486
9487
|
static unique_ptr<CreateFunctionInfo> GetDefaultFunction(const string &schema, const string &name) {
|
|
@@ -11177,6 +11178,8 @@ string PhysicalOperatorToString(PhysicalOperatorType type) {
|
|
|
11177
11178
|
return "CREATE_INDEX";
|
|
11178
11179
|
case PhysicalOperatorType::EXPLAIN:
|
|
11179
11180
|
return "EXPLAIN";
|
|
11181
|
+
case PhysicalOperatorType::EXPLAIN_ANALYZE:
|
|
11182
|
+
return "EXPLAIN_ANALYZE";
|
|
11180
11183
|
case PhysicalOperatorType::EXECUTE:
|
|
11181
11184
|
return "EXECUTE";
|
|
11182
11185
|
case PhysicalOperatorType::VACUUM:
|
|
@@ -31970,6 +31973,7 @@ struct ExpressionInfo {
|
|
|
31970
31973
|
vector<unique_ptr<ExpressionInfo>> children;
|
|
31971
31974
|
// Extract ExpressionInformation from a given expression state
|
|
31972
31975
|
void ExtractExpressionsRecursive(unique_ptr<ExpressionState> &state);
|
|
31976
|
+
|
|
31973
31977
|
//! Whether or not expression has function
|
|
31974
31978
|
bool hasfunction;
|
|
31975
31979
|
//! The function Name
|
|
@@ -31985,6 +31989,7 @@ struct ExpressionInfo {
|
|
|
31985
31989
|
//! The ExpressionRootInfo keeps information related to the root of an expression tree
|
|
31986
31990
|
struct ExpressionRootInfo {
|
|
31987
31991
|
ExpressionRootInfo(ExpressionExecutorState &executor, string name);
|
|
31992
|
+
|
|
31988
31993
|
//! Count the number of time the executor called
|
|
31989
31994
|
uint64_t total_count = 0;
|
|
31990
31995
|
//! Count the number of time the executor called since last sampling
|
|
@@ -32008,6 +32013,7 @@ struct ExpressionRootInfo {
|
|
|
32008
32013
|
struct ExpressionExecutorInfo {
|
|
32009
32014
|
explicit ExpressionExecutorInfo() {};
|
|
32010
32015
|
explicit ExpressionExecutorInfo(ExpressionExecutor &executor, const string &name, int id);
|
|
32016
|
+
|
|
32011
32017
|
//! A vector which contain the pointer to all ExpressionRootInfo
|
|
32012
32018
|
vector<unique_ptr<ExpressionRootInfo>> roots;
|
|
32013
32019
|
//! Id, it will be used as index for executors_info vector
|
|
@@ -32015,11 +32021,12 @@ struct ExpressionExecutorInfo {
|
|
|
32015
32021
|
};
|
|
32016
32022
|
|
|
32017
32023
|
struct OperatorInformation {
|
|
32024
|
+
explicit OperatorInformation(double time_ = 0, idx_t elements_ = 0) : time(time_), elements(elements_) {
|
|
32025
|
+
}
|
|
32026
|
+
|
|
32018
32027
|
double time = 0;
|
|
32019
32028
|
idx_t elements = 0;
|
|
32020
32029
|
string name;
|
|
32021
|
-
explicit OperatorInformation(double time_ = 0, idx_t elements_ = 0) : time(time_), elements(elements_) {
|
|
32022
|
-
}
|
|
32023
32030
|
//! A vector of Expression Executor Info
|
|
32024
32031
|
vector<unique_ptr<ExpressionExecutorInfo>> executors_info;
|
|
32025
32032
|
};
|
|
@@ -32057,9 +32064,16 @@ class QueryProfiler {
|
|
|
32057
32064
|
public:
|
|
32058
32065
|
DUCKDB_API QueryProfiler()
|
|
32059
32066
|
: automatic_print_format(ProfilerPrintFormat::NONE), enabled(false), detailed_enabled(false), running(false),
|
|
32060
|
-
query_requires_profiling(false)
|
|
32067
|
+
query_requires_profiling(false), is_explain_analyze(false), stored_enabled(false),
|
|
32068
|
+
stored_automatic_print_format(ProfilerPrintFormat::NONE) {
|
|
32061
32069
|
}
|
|
32062
32070
|
|
|
32071
|
+
//! The format to automatically print query profiling information in (default: disabled)
|
|
32072
|
+
ProfilerPrintFormat automatic_print_format;
|
|
32073
|
+
//! The file to save query profiling information to, instead of printing it to the console (empty = print to
|
|
32074
|
+
//! console)
|
|
32075
|
+
string save_location;
|
|
32076
|
+
|
|
32063
32077
|
public:
|
|
32064
32078
|
struct TreeNode {
|
|
32065
32079
|
PhysicalOperatorType type;
|
|
@@ -32103,9 +32117,11 @@ public:
|
|
|
32103
32117
|
return detailed_enabled;
|
|
32104
32118
|
}
|
|
32105
32119
|
|
|
32106
|
-
DUCKDB_API void StartQuery(string query);
|
|
32120
|
+
DUCKDB_API void StartQuery(string query, bool is_explain_analyze = false);
|
|
32107
32121
|
DUCKDB_API void EndQuery();
|
|
32108
32122
|
|
|
32123
|
+
DUCKDB_API void StartExplainAnalyze();
|
|
32124
|
+
|
|
32109
32125
|
//! Adds the timings gathered by an OperatorProfiler to this query profiler
|
|
32110
32126
|
DUCKDB_API void Flush(OperatorProfiler &profiler);
|
|
32111
32127
|
|
|
@@ -32121,12 +32137,6 @@ public:
|
|
|
32121
32137
|
DUCKDB_API string ToJSON() const;
|
|
32122
32138
|
DUCKDB_API void WriteToFile(const char *path, string &info) const;
|
|
32123
32139
|
|
|
32124
|
-
//! The format to automatically print query profiling information in (default: disabled)
|
|
32125
|
-
ProfilerPrintFormat automatic_print_format;
|
|
32126
|
-
//! The file to save query profiling information to, instead of printing it to the console (empty = print to
|
|
32127
|
-
//! console)
|
|
32128
|
-
string save_location;
|
|
32129
|
-
|
|
32130
32140
|
idx_t OperatorSize() {
|
|
32131
32141
|
return tree_map.size();
|
|
32132
32142
|
}
|
|
@@ -32152,6 +32162,11 @@ private:
|
|
|
32152
32162
|
//! A map of a Physical Operator pointer to a tree node
|
|
32153
32163
|
TreeMap tree_map;
|
|
32154
32164
|
|
|
32165
|
+
bool is_explain_analyze;
|
|
32166
|
+
bool stored_enabled;
|
|
32167
|
+
ProfilerPrintFormat stored_automatic_print_format;
|
|
32168
|
+
string stored_save_location;
|
|
32169
|
+
|
|
32155
32170
|
public:
|
|
32156
32171
|
const TreeMap &GetTreeMap() const {
|
|
32157
32172
|
return tree_map;
|
|
@@ -54034,7 +54049,6 @@ public:
|
|
|
54034
54049
|
}
|
|
54035
54050
|
|
|
54036
54051
|
bool ParallelSink() const override {
|
|
54037
|
-
// we can only parallelize if all aggregates are combinable
|
|
54038
54052
|
return true;
|
|
54039
54053
|
}
|
|
54040
54054
|
};
|
|
@@ -56018,6 +56032,112 @@ PhysicalExecute::PhysicalExecute(PhysicalOperator *plan)
|
|
|
56018
56032
|
: PhysicalOperator(PhysicalOperatorType::EXECUTE, plan->types, -1), plan(plan) {
|
|
56019
56033
|
}
|
|
56020
56034
|
|
|
56035
|
+
} // namespace duckdb
|
|
56036
|
+
//===----------------------------------------------------------------------===//
|
|
56037
|
+
// DuckDB
|
|
56038
|
+
//
|
|
56039
|
+
// duckdb/execution/operator/helper/physical_explain_analyze.hpp
|
|
56040
|
+
//
|
|
56041
|
+
//
|
|
56042
|
+
//===----------------------------------------------------------------------===//
|
|
56043
|
+
|
|
56044
|
+
|
|
56045
|
+
|
|
56046
|
+
|
|
56047
|
+
|
|
56048
|
+
|
|
56049
|
+
namespace duckdb {
|
|
56050
|
+
|
|
56051
|
+
class PhysicalExplainAnalyze : public PhysicalOperator {
|
|
56052
|
+
public:
|
|
56053
|
+
PhysicalExplainAnalyze(vector<LogicalType> types)
|
|
56054
|
+
: PhysicalOperator(PhysicalOperatorType::EXPLAIN_ANALYZE, move(types), 1) {
|
|
56055
|
+
}
|
|
56056
|
+
|
|
56057
|
+
public:
|
|
56058
|
+
// Source interface
|
|
56059
|
+
unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
|
|
56060
|
+
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
|
56061
|
+
LocalSourceState &lstate) const override;
|
|
56062
|
+
|
|
56063
|
+
public:
|
|
56064
|
+
// Sink Interface
|
|
56065
|
+
SinkResultType Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
|
|
56066
|
+
DataChunk &input) const override;
|
|
56067
|
+
SinkFinalizeType Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
|
|
56068
|
+
GlobalSinkState &gstate) const override;
|
|
56069
|
+
|
|
56070
|
+
unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
|
|
56071
|
+
|
|
56072
|
+
bool IsSink() const override {
|
|
56073
|
+
return true;
|
|
56074
|
+
}
|
|
56075
|
+
|
|
56076
|
+
bool ParallelSink() const override {
|
|
56077
|
+
return true;
|
|
56078
|
+
}
|
|
56079
|
+
};
|
|
56080
|
+
|
|
56081
|
+
} // namespace duckdb
|
|
56082
|
+
|
|
56083
|
+
|
|
56084
|
+
|
|
56085
|
+
|
|
56086
|
+
namespace duckdb {
|
|
56087
|
+
|
|
56088
|
+
//===--------------------------------------------------------------------===//
|
|
56089
|
+
// Sink
|
|
56090
|
+
//===--------------------------------------------------------------------===//
|
|
56091
|
+
class ExplainAnalyzeStateGlobalState : public GlobalSinkState {
|
|
56092
|
+
public:
|
|
56093
|
+
string analyzed_plan;
|
|
56094
|
+
};
|
|
56095
|
+
|
|
56096
|
+
SinkResultType PhysicalExplainAnalyze::Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
|
|
56097
|
+
DataChunk &input) const {
|
|
56098
|
+
return SinkResultType::NEED_MORE_INPUT;
|
|
56099
|
+
}
|
|
56100
|
+
|
|
56101
|
+
SinkFinalizeType PhysicalExplainAnalyze::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
|
|
56102
|
+
GlobalSinkState &gstate_p) const {
|
|
56103
|
+
auto &gstate = (ExplainAnalyzeStateGlobalState &)gstate_p;
|
|
56104
|
+
gstate.analyzed_plan = context.profiler->ToString();
|
|
56105
|
+
return SinkFinalizeType::READY;
|
|
56106
|
+
}
|
|
56107
|
+
|
|
56108
|
+
unique_ptr<GlobalSinkState> PhysicalExplainAnalyze::GetGlobalSinkState(ClientContext &context) const {
|
|
56109
|
+
return make_unique<ExplainAnalyzeStateGlobalState>();
|
|
56110
|
+
}
|
|
56111
|
+
|
|
56112
|
+
//===--------------------------------------------------------------------===//
|
|
56113
|
+
// Source
|
|
56114
|
+
//===--------------------------------------------------------------------===//
|
|
56115
|
+
class ExplainAnalyzeState : public GlobalSourceState {
|
|
56116
|
+
public:
|
|
56117
|
+
ExplainAnalyzeState() : finished(false) {
|
|
56118
|
+
}
|
|
56119
|
+
|
|
56120
|
+
bool finished;
|
|
56121
|
+
};
|
|
56122
|
+
|
|
56123
|
+
unique_ptr<GlobalSourceState> PhysicalExplainAnalyze::GetGlobalSourceState(ClientContext &context) const {
|
|
56124
|
+
return make_unique<ExplainAnalyzeState>();
|
|
56125
|
+
}
|
|
56126
|
+
|
|
56127
|
+
void PhysicalExplainAnalyze::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &source_state,
|
|
56128
|
+
LocalSourceState &lstate) const {
|
|
56129
|
+
auto &state = (ExplainAnalyzeState &)source_state;
|
|
56130
|
+
auto &gstate = (ExplainAnalyzeStateGlobalState &)*sink_state;
|
|
56131
|
+
if (state.finished) {
|
|
56132
|
+
return;
|
|
56133
|
+
}
|
|
56134
|
+
chunk.SetValue(0, 0, Value("analyzed_plan"));
|
|
56135
|
+
chunk.SetValue(1, 0, Value(gstate.analyzed_plan));
|
|
56136
|
+
chunk.SetCardinality(1);
|
|
56137
|
+
|
|
56138
|
+
state.finished = true;
|
|
56139
|
+
}
|
|
56140
|
+
|
|
56021
56141
|
} // namespace duckdb
|
|
56022
56142
|
//===----------------------------------------------------------------------===//
|
|
56023
56143
|
// DuckDB
|
|
@@ -67794,15 +67914,47 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalExecute &o
|
|
|
67794
67914
|
|
|
67795
67915
|
|
|
67796
67916
|
|
|
67917
|
+
//===----------------------------------------------------------------------===//
|
|
67918
|
+
// DuckDB
|
|
67919
|
+
//
|
|
67920
|
+
// duckdb/parser/statement/explain_statement.hpp
|
|
67921
|
+
//
|
|
67922
|
+
//
|
|
67923
|
+
//===----------------------------------------------------------------------===//
|
|
67924
|
+
|
|
67925
|
+
|
|
67926
|
+
|
|
67927
|
+
|
|
67928
|
+
|
|
67929
|
+
|
|
67930
|
+
namespace duckdb {
|
|
67931
|
+
|
|
67932
|
+
enum class ExplainType : uint8_t { EXPLAIN_STANDARD, EXPLAIN_ANALYZE };
|
|
67933
|
+
|
|
67934
|
+
class ExplainStatement : public SQLStatement {
|
|
67935
|
+
public:
|
|
67936
|
+
ExplainStatement(unique_ptr<SQLStatement> stmt, ExplainType explain_type = ExplainType::EXPLAIN_STANDARD);
|
|
67937
|
+
|
|
67938
|
+
unique_ptr<SQLStatement> stmt;
|
|
67939
|
+
ExplainType explain_type;
|
|
67940
|
+
|
|
67941
|
+
public:
|
|
67942
|
+
unique_ptr<SQLStatement> Copy() const override;
|
|
67943
|
+
};
|
|
67944
|
+
|
|
67945
|
+
} // namespace duckdb
|
|
67946
|
+
|
|
67797
67947
|
|
|
67798
67948
|
namespace duckdb {
|
|
67799
67949
|
|
|
67800
67950
|
class LogicalExplain : public LogicalOperator {
|
|
67801
67951
|
public:
|
|
67802
|
-
|
|
67952
|
+
LogicalExplain(unique_ptr<LogicalOperator> plan, ExplainType explain_type)
|
|
67953
|
+
: LogicalOperator(LogicalOperatorType::LOGICAL_EXPLAIN), explain_type(explain_type) {
|
|
67803
67954
|
children.push_back(move(plan));
|
|
67804
67955
|
}
|
|
67805
67956
|
|
|
67957
|
+
ExplainType explain_type;
|
|
67806
67958
|
string physical_plan;
|
|
67807
67959
|
string logical_plan_unopt;
|
|
67808
67960
|
string logical_plan_opt;
|
|
@@ -67821,15 +67973,20 @@ protected:
|
|
|
67821
67973
|
|
|
67822
67974
|
|
|
67823
67975
|
|
|
67976
|
+
|
|
67824
67977
|
namespace duckdb {
|
|
67825
67978
|
|
|
67826
67979
|
unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalExplain &op) {
|
|
67827
67980
|
D_ASSERT(op.children.size() == 1);
|
|
67828
67981
|
auto logical_plan_opt = op.children[0]->ToString();
|
|
67829
67982
|
auto plan = CreatePlan(*op.children[0]);
|
|
67983
|
+
if (op.explain_type == ExplainType::EXPLAIN_ANALYZE) {
|
|
67984
|
+
auto result = make_unique<PhysicalExplainAnalyze>(op.types);
|
|
67985
|
+
result->children.push_back(move(plan));
|
|
67986
|
+
return move(result);
|
|
67987
|
+
}
|
|
67830
67988
|
|
|
67831
67989
|
op.physical_plan = plan->ToString();
|
|
67832
|
-
|
|
67833
67990
|
// the output of the explain
|
|
67834
67991
|
vector<string> keys, values;
|
|
67835
67992
|
switch (context.explain_output_type) {
|
|
@@ -79278,6 +79435,14 @@ static void PragmaDisableForceExternal(ClientContext &context, const FunctionPar
|
|
|
79278
79435
|
context.force_external = false;
|
|
79279
79436
|
}
|
|
79280
79437
|
|
|
79438
|
+
static void PragmaEnableParquetBinaryAsString(ClientContext &context, const FunctionParameters ¶meters) {
|
|
79439
|
+
context.parquet_binary_as_strings = true;
|
|
79440
|
+
}
|
|
79441
|
+
|
|
79442
|
+
static void PragmaDisableParquetBinaryAsString(ClientContext &context, const FunctionParameters ¶meters) {
|
|
79443
|
+
context.parquet_binary_as_strings = false;
|
|
79444
|
+
}
|
|
79445
|
+
|
|
79281
79446
|
static void PragmaEnableObjectCache(ClientContext &context, const FunctionParameters ¶meters) {
|
|
79282
79447
|
DBConfig::GetConfig(context).object_cache_enable = true;
|
|
79283
79448
|
}
|
|
@@ -79453,6 +79618,11 @@ void PragmaFunctions::RegisterFunction(BuiltinFunctions &set) {
|
|
|
79453
79618
|
set.AddFunction(PragmaFunction::PragmaStatement("enable_print_progress_bar", PragmaEnablePrintProgressBar));
|
|
79454
79619
|
set.AddFunction(PragmaFunction::PragmaStatement("disable_print_progress_bar", PragmaDisablePrintProgressBar));
|
|
79455
79620
|
|
|
79621
|
+
set.AddFunction(
|
|
79622
|
+
PragmaFunction::PragmaStatement("enable_parquet_binary_as_string", PragmaEnableParquetBinaryAsString));
|
|
79623
|
+
set.AddFunction(
|
|
79624
|
+
PragmaFunction::PragmaStatement("disable_parquet_binary_as_string", PragmaDisableParquetBinaryAsString));
|
|
79625
|
+
|
|
79456
79626
|
set.AddFunction(
|
|
79457
79627
|
PragmaFunction::PragmaAssignment("set_progress_bar_time", PragmaSetProgressBarWaitTime, LogicalType::INTEGER));
|
|
79458
79628
|
|
|
@@ -100949,32 +101119,6 @@ public:
|
|
|
100949
101119
|
};
|
|
100950
101120
|
} // namespace duckdb
|
|
100951
101121
|
|
|
100952
|
-
//===----------------------------------------------------------------------===//
|
|
100953
|
-
// DuckDB
|
|
100954
|
-
//
|
|
100955
|
-
// duckdb/parser/statement/explain_statement.hpp
|
|
100956
|
-
//
|
|
100957
|
-
//
|
|
100958
|
-
//===----------------------------------------------------------------------===//
|
|
100959
|
-
|
|
100960
|
-
|
|
100961
|
-
|
|
100962
|
-
|
|
100963
|
-
|
|
100964
|
-
|
|
100965
|
-
namespace duckdb {
|
|
100966
|
-
|
|
100967
|
-
class ExplainStatement : public SQLStatement {
|
|
100968
|
-
public:
|
|
100969
|
-
explicit ExplainStatement(unique_ptr<SQLStatement> stmt);
|
|
100970
|
-
|
|
100971
|
-
unique_ptr<SQLStatement> stmt;
|
|
100972
|
-
|
|
100973
|
-
public:
|
|
100974
|
-
unique_ptr<SQLStatement> Copy() const override;
|
|
100975
|
-
};
|
|
100976
|
-
|
|
100977
|
-
} // namespace duckdb
|
|
100978
101122
|
|
|
100979
101123
|
//===----------------------------------------------------------------------===//
|
|
100980
101124
|
// DuckDB
|
|
@@ -101529,6 +101673,17 @@ unique_ptr<QueryResult> ClientContext::RunStatementInternal(ClientContextLock &l
|
|
|
101529
101673
|
return ExecutePreparedStatement(lock, query, move(prepared), move(bound_values), allow_stream_result);
|
|
101530
101674
|
}
|
|
101531
101675
|
|
|
101676
|
+
static bool IsExplainAnalyze(SQLStatement *statement) {
|
|
101677
|
+
if (!statement) {
|
|
101678
|
+
return false;
|
|
101679
|
+
}
|
|
101680
|
+
if (statement->type != StatementType::EXPLAIN_STATEMENT) {
|
|
101681
|
+
return false;
|
|
101682
|
+
}
|
|
101683
|
+
auto &explain = (ExplainStatement &)*statement;
|
|
101684
|
+
return explain.explain_type == ExplainType::EXPLAIN_ANALYZE;
|
|
101685
|
+
}
|
|
101686
|
+
|
|
101532
101687
|
unique_ptr<QueryResult> ClientContext::RunStatementOrPreparedStatement(ClientContextLock &lock, const string &query,
|
|
101533
101688
|
unique_ptr<SQLStatement> statement,
|
|
101534
101689
|
shared_ptr<PreparedStatementData> &prepared,
|
|
@@ -101560,7 +101715,7 @@ unique_ptr<QueryResult> ClientContext::RunStatementOrPreparedStatement(ClientCon
|
|
|
101560
101715
|
statement = move(copied_statement);
|
|
101561
101716
|
}
|
|
101562
101717
|
// start the profiler
|
|
101563
|
-
profiler->StartQuery(query);
|
|
101718
|
+
profiler->StartQuery(query, IsExplainAnalyze(statement ? statement.get() : prepared->unbound_statement.get()));
|
|
101564
101719
|
try {
|
|
101565
101720
|
if (statement) {
|
|
101566
101721
|
result = RunStatementInternal(lock, query, move(statement), allow_stream_result);
|
|
@@ -103348,7 +103503,10 @@ using std::ofstream;
|
|
|
103348
103503
|
|
|
103349
103504
|
namespace duckdb {
|
|
103350
103505
|
|
|
103351
|
-
void QueryProfiler::StartQuery(string query) {
|
|
103506
|
+
void QueryProfiler::StartQuery(string query, bool is_explain_analyze) {
|
|
103507
|
+
if (is_explain_analyze) {
|
|
103508
|
+
StartExplainAnalyze();
|
|
103509
|
+
}
|
|
103352
103510
|
if (!enabled) {
|
|
103353
103511
|
return;
|
|
103354
103512
|
}
|
|
@@ -103404,6 +103562,17 @@ void QueryProfiler::Finalize(TreeNode &node) {
|
|
|
103404
103562
|
}
|
|
103405
103563
|
}
|
|
103406
103564
|
|
|
103565
|
+
void QueryProfiler::StartExplainAnalyze() {
|
|
103566
|
+
this->is_explain_analyze = true;
|
|
103567
|
+
this->stored_enabled = enabled;
|
|
103568
|
+
this->stored_automatic_print_format = automatic_print_format;
|
|
103569
|
+
this->stored_save_location = save_location;
|
|
103570
|
+
|
|
103571
|
+
this->enabled = true;
|
|
103572
|
+
this->save_location = string();
|
|
103573
|
+
this->automatic_print_format = ProfilerPrintFormat::NONE;
|
|
103574
|
+
}
|
|
103575
|
+
|
|
103407
103576
|
void QueryProfiler::EndQuery() {
|
|
103408
103577
|
if (!enabled || !running) {
|
|
103409
103578
|
return;
|
|
@@ -103433,6 +103602,12 @@ void QueryProfiler::EndQuery() {
|
|
|
103433
103602
|
WriteToFile(save_location.c_str(), query_info);
|
|
103434
103603
|
}
|
|
103435
103604
|
}
|
|
103605
|
+
if (is_explain_analyze) {
|
|
103606
|
+
this->is_explain_analyze = false;
|
|
103607
|
+
this->enabled = stored_enabled;
|
|
103608
|
+
this->automatic_print_format = stored_automatic_print_format;
|
|
103609
|
+
this->save_location = stored_save_location;
|
|
103610
|
+
}
|
|
103436
103611
|
}
|
|
103437
103612
|
|
|
103438
103613
|
void QueryProfiler::StartPhase(string new_phase) {
|
|
@@ -116078,6 +116253,7 @@ void Executor::BuildPipelines(PhysicalOperator *op, Pipeline *current) {
|
|
|
116078
116253
|
case PhysicalOperatorType::COPY_TO_FILE:
|
|
116079
116254
|
case PhysicalOperatorType::LIMIT:
|
|
116080
116255
|
case PhysicalOperatorType::EXPRESSION_SCAN:
|
|
116256
|
+
case PhysicalOperatorType::EXPLAIN_ANALYZE:
|
|
116081
116257
|
D_ASSERT(op->children.size() == 1);
|
|
116082
116258
|
// single operator:
|
|
116083
116259
|
// the operator becomes the data source of the current pipeline
|
|
@@ -130320,12 +130496,12 @@ unique_ptr<SQLStatement> ExecuteStatement::Copy() const {
|
|
|
130320
130496
|
|
|
130321
130497
|
namespace duckdb {
|
|
130322
130498
|
|
|
130323
|
-
ExplainStatement::ExplainStatement(unique_ptr<SQLStatement> stmt)
|
|
130324
|
-
: SQLStatement(StatementType::EXPLAIN_STATEMENT), stmt(move(stmt)) {
|
|
130499
|
+
ExplainStatement::ExplainStatement(unique_ptr<SQLStatement> stmt, ExplainType explain_type)
|
|
130500
|
+
: SQLStatement(StatementType::EXPLAIN_STATEMENT), stmt(move(stmt)), explain_type(explain_type) {
|
|
130325
130501
|
}
|
|
130326
130502
|
|
|
130327
130503
|
unique_ptr<SQLStatement> ExplainStatement::Copy() const {
|
|
130328
|
-
auto result = make_unique<ExplainStatement>(stmt->Copy());
|
|
130504
|
+
auto result = make_unique<ExplainStatement>(stmt->Copy(), explain_type);
|
|
130329
130505
|
return move(result);
|
|
130330
130506
|
}
|
|
130331
130507
|
|
|
@@ -134584,7 +134760,19 @@ namespace duckdb {
|
|
|
134584
134760
|
unique_ptr<ExplainStatement> Transformer::TransformExplain(duckdb_libpgquery::PGNode *node) {
|
|
134585
134761
|
auto stmt = reinterpret_cast<duckdb_libpgquery::PGExplainStmt *>(node);
|
|
134586
134762
|
D_ASSERT(stmt);
|
|
134587
|
-
|
|
134763
|
+
auto explain_type = ExplainType::EXPLAIN_STANDARD;
|
|
134764
|
+
if (stmt->options) {
|
|
134765
|
+
for (auto n = stmt->options->head; n; n = n->next) {
|
|
134766
|
+
auto def_elem = ((duckdb_libpgquery::PGDefElem *)n->data.ptr_value)->defname;
|
|
134767
|
+
string elem(def_elem);
|
|
134768
|
+
if (elem == "analyze") {
|
|
134769
|
+
explain_type = ExplainType::EXPLAIN_ANALYZE;
|
|
134770
|
+
} else {
|
|
134771
|
+
throw NotImplementedException("Unimplemented explain type: %s", elem);
|
|
134772
|
+
}
|
|
134773
|
+
}
|
|
134774
|
+
}
|
|
134775
|
+
return make_unique<ExplainStatement>(TransformStatement(stmt->query), explain_type);
|
|
134588
134776
|
}
|
|
134589
134777
|
|
|
134590
134778
|
} // namespace duckdb
|
|
@@ -140177,7 +140365,7 @@ BoundStatement Binder::Bind(ExplainStatement &stmt) {
|
|
|
140177
140365
|
auto plan = Bind(*stmt.stmt);
|
|
140178
140366
|
// get the unoptimized logical plan, and create the explain statement
|
|
140179
140367
|
auto logical_plan_unopt = plan.plan->ToString();
|
|
140180
|
-
auto explain = make_unique<LogicalExplain>(move(plan.plan));
|
|
140368
|
+
auto explain = make_unique<LogicalExplain>(move(plan.plan), stmt.explain_type);
|
|
140181
140369
|
explain->logical_plan_unopt = logical_plan_unopt;
|
|
140182
140370
|
|
|
140183
140371
|
result.plan = move(explain);
|
package/src/duckdb.hpp
CHANGED
|
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
|
-
#define DUCKDB_SOURCE_ID "
|
|
14
|
-
#define DUCKDB_VERSION "0.3.2-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "7a1864144"
|
|
14
|
+
#define DUCKDB_VERSION "0.3.2-dev70"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|
|
@@ -12697,6 +12697,7 @@ enum class PhysicalOperatorType : uint8_t {
|
|
|
12697
12697
|
// Helpers
|
|
12698
12698
|
// -----------------------------
|
|
12699
12699
|
EXPLAIN,
|
|
12700
|
+
EXPLAIN_ANALYZE,
|
|
12700
12701
|
EMPTY_RESULT,
|
|
12701
12702
|
EXECUTE,
|
|
12702
12703
|
PREPARE,
|
|
@@ -13613,6 +13614,8 @@ public:
|
|
|
13613
13614
|
bool force_index_join = false;
|
|
13614
13615
|
//! Force out-of-core computation for operators that support it, used for testing
|
|
13615
13616
|
bool force_external = false;
|
|
13617
|
+
//! If binaries should be converted to strings by default on the parquet reader
|
|
13618
|
+
bool parquet_binary_as_strings = false;
|
|
13616
13619
|
//! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
|
|
13617
13620
|
//! elements)
|
|
13618
13621
|
idx_t perfect_ht_threshold = 12;
|